From 024f68ba4868ac7d7da2d076b08df5fb32c53461 Mon Sep 17 00:00:00 2001 From: Jared Goodwin Date: Sat, 23 Mar 2019 12:26:45 -0700 Subject: [PATCH] Added app settings for redirect to HTTPS and use HSTS. --- Remotely_Server/CurrentVersion.txt | 2 +- Remotely_Server/Services/ApplicationConfig.cs | 2 ++ Remotely_Server/Startup.cs | 10 ++++++++-- Remotely_Server/appsettings.json | 2 ++ 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Remotely_Server/CurrentVersion.txt b/Remotely_Server/CurrentVersion.txt index 97af5b9f..5b428a85 100644 --- a/Remotely_Server/CurrentVersion.txt +++ b/Remotely_Server/CurrentVersion.txt @@ -1 +1 @@ -2019.03.20.2311 +2019.03.23.1213 diff --git a/Remotely_Server/Services/ApplicationConfig.cs b/Remotely_Server/Services/ApplicationConfig.cs index fb37fbc3..9452b5c5 100644 --- a/Remotely_Server/Services/ApplicationConfig.cs +++ b/Remotely_Server/Services/ApplicationConfig.cs @@ -20,6 +20,8 @@ namespace Remotely_Server.Services public double DataRetentionInDays => double.Parse(Config["ApplicationOptions:DataRetentionInDays"]); public double RemoteControlSessionLimit => double.Parse(Config["ApplicationOptions:RemoteControlSessionLimit"]); public bool RecordRemoteControlSessions => bool.Parse(Config["ApplicationOptions:RecordRemoteControlSessions"]); + public bool RedirectToHTTPS => bool.Parse(Config["ApplicationOptions:RedirectToHTTPS"]); + public bool UseHSTS => bool.Parse(Config["ApplicationOptions:RedirectToHTTPS"]); public string SmtpHost => Config["ApplicationOptions:SmtpHost"]; public int SmtpPort => int.Parse(Config["ApplicationOptions:SmtpPort"]); diff --git a/Remotely_Server/Startup.cs b/Remotely_Server/Startup.cs index 4032fbee..f9e88e90 100644 --- a/Remotely_Server/Startup.cs +++ b/Remotely_Server/Startup.cs @@ -111,8 +111,14 @@ namespace Remotely_Server else { app.UseExceptionHandler("/Error"); - app.UseHsts(); - app.UseHttpsRedirection(); + if (bool.Parse(Configuration["ApplicationOptions:UseHSTS"])) + { + app.UseHsts(); + } + if (bool.Parse(Configuration["ApplicationOptions:RedirectToHTTPS"])) + { + app.UseHttpsRedirection(); + } } ConfigureStaticFiles(app); diff --git a/Remotely_Server/appsettings.json b/Remotely_Server/appsettings.json index 25136e34..07411b24 100644 --- a/Remotely_Server/appsettings.json +++ b/Remotely_Server/appsettings.json @@ -14,6 +14,8 @@ "DBProvider": "SQLite", "AllowSelfRegistration": true, "RecordRemoteControlSessions": false, + "RedirectToHTTPS": false, + "UseHSTS": false, "DataRetentionInDays": 90, "RemoteControlSessionLimit": 1, "SmtpHost": "",