Merge remote-tracking branch 'origin/v9/dev' into v9/dev

This commit is contained in:
Bjarke Berg
2021-09-16 14:20:12 +02:00
5 changed files with 37 additions and 8 deletions

View File

@@ -32,6 +32,10 @@
"NoNodesViewPath":{
"longName": "no-nodes-view-path",
"shortName": ""
},
"UseHttpsRedirect": {
"longName": "use-https-redirect",
"shortName": ""
}
},
"usageExamples": [

View File

@@ -62,6 +62,13 @@
"text": "Optional: Path to a custom view presented with the Umbraco installation contains no published content"
},
"isVisible": "true"
},
{
"id": "UseHttpsRedirect",
"name": {
"text": "Optional: Adds code to Startup.cs to redirect HTTP to HTTPS and enables the UseHttps setting."
},
"isVisible": "true"
}
]
}

View File

@@ -293,6 +293,12 @@
"UsingUnattenedInstall":{
"type": "computed",
"value": "(FriendlyName != \"\" && Email != \"\" && Password != \"\" && ConnectionString != \"\")"
},
"UseHttpsRedirect":{
"type": "parameter",
"datatype":"bool",
"defaultValue": "false",
"description": "Adds code to Startup.cs to redirect HTTP to HTTPS and enables the UseHttps setting (Default: false)"
}
}
}

View File

@@ -15,9 +15,16 @@
},
"Umbraco": {
"CMS": {
//#if (HasNoNodesViewPath)
//#if (HasNoNodesViewPath || UseHttpsRedirect)
"Global": {
//#if (!HasNoNodesViewPath && UseHttpsRedirect)
"UseHttps": true
//#elseif (UseHttpsRedirect)
"UseHttps": true,
//#endif
//#if (HasNoNodesViewPath)
"NoNodesViewPath": "NO_NODES_VIEW_PATH_FROM_TEMPLATE"
//#endif
},
//#endif
"Hosting": {

View File

@@ -15,10 +15,10 @@ namespace Umbraco.Cms.Web.UI
private readonly IConfiguration _config;
/// <summary>
/// Initializes a new instance of the <see cref="Startup"/> class.
/// Initializes a new instance of the <see cref="Startup" /> class.
/// </summary>
/// <param name="webHostEnvironment">The Web Host Environment</param>
/// <param name="config">The Configuration</param>
/// <param name="webHostEnvironment">The web hosting environment.</param>
/// <param name="config">The configuration.</param>
/// <remarks>
/// Only a few services are possible to be injected here https://github.com/dotnet/aspnetcore/issues/9337
/// </remarks>
@@ -28,11 +28,10 @@ namespace Umbraco.Cms.Web.UI
_config = config ?? throw new ArgumentNullException(nameof(config));
}
/// <summary>
/// Configures the services
/// Configures the services.
/// </summary>
/// <param name="services">The services.</param>
/// <remarks>
/// This method gets called by the runtime. Use this method to add services to the container.
/// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
@@ -50,8 +49,10 @@ namespace Umbraco.Cms.Web.UI
}
/// <summary>
/// Configures the application
/// Configures the application.
/// </summary>
/// <param name="app">The application builder.</param>
/// <param name="env">The web hosting environment.</param>
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
@@ -59,6 +60,10 @@ namespace Umbraco.Cms.Web.UI
app.UseDeveloperExceptionPage();
}
#if (UseHttpsRedirect)
app.UseHttpsRedirection();
#endif
app.UseUmbraco()
.WithMiddleware(u =>
{