Skip to content

Commit

Permalink
Force SSL option added
Browse files Browse the repository at this point in the history
  • Loading branch information
madskristensen committed Sep 3, 2017
1 parent e6734ce commit a33887d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Pages/_ViewStart.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
if (Context.Request.IsHttps)
{
Context.Response.Headers["Strict-Transport-Security"] = "max-age=63072000";
Context.Response.Headers["Strict-Transport-Security"] = "max-age=63072000; includeSubDomains";
}
}
6 changes: 6 additions & 0 deletions src/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Rewrite;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Net.Http.Headers;
Expand Down Expand Up @@ -73,6 +74,11 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env)
}
});

if (Configuration.GetValue<bool>("forcessl"))
{
app.UseRewriter(new RewriteOptions().AddRedirectToHttps());
}

app.UseMvc(routes =>
{
routes.MapRoute(
Expand Down
1 change: 1 addition & 0 deletions src/appsettings.Production.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"forcessl": false, // Set to true if you run https
"Logging": {
"IncludeScopes": false,
"Debug": {
Expand Down
1 change: 1 addition & 0 deletions src/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"forcessl": false,
"user": {
"username": "demo",
// Generate a new password hash with salt here https://onlinehasher.azurewebsites.net/
Expand Down

0 comments on commit a33887d

Please sign in to comment.