From 4bed5c1a9acbd52ba8d116ceee905c3dd6f05427 Mon Sep 17 00:00:00 2001 From: Sebastien Ros Date: Fri, 14 Mar 2014 17:36:56 -0700 Subject: [PATCH] #20230: Fix SSL when custom pages are not matched Work Item: 20230 --- .../Models/SslSettingsPart.cs | 3 +++ .../Services/SecureSocketsLayerService.cs | 4 ++++ .../Parts/SecureSocketsLayer.Settings.cshtml | 20 +++++++++---------- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/Orchard.Web/Modules/Orchard.SecureSocketsLayer/Models/SslSettingsPart.cs b/src/Orchard.Web/Modules/Orchard.SecureSocketsLayer/Models/SslSettingsPart.cs index 856833efa..fe4d0ff62 100644 --- a/src/Orchard.Web/Modules/Orchard.SecureSocketsLayer/Models/SslSettingsPart.cs +++ b/src/Orchard.Web/Modules/Orchard.SecureSocketsLayer/Models/SslSettingsPart.cs @@ -1,4 +1,5 @@ using System; +using System.ComponentModel.DataAnnotations; using Orchard.ContentManagement; using Orchard.ContentManagement.FieldStorage.InfosetStorage; @@ -45,11 +46,13 @@ namespace Orchard.SecureSocketsLayer.Models { set { this.As().Set("CustomEnabled", value.ToString()); } } + [Required] public string SecureHostName { get { return this.As().Get("SecureHostName"); } set { this.As().Set("SecureHostName", value); } } + [Required] public string InsecureHostName { get { return this.As().Get("InsecureHostName"); } set { this.As().Set("InsecureHostName", value); } diff --git a/src/Orchard.Web/Modules/Orchard.SecureSocketsLayer/Services/SecureSocketsLayerService.cs b/src/Orchard.Web/Modules/Orchard.SecureSocketsLayer/Services/SecureSocketsLayerService.cs index aa4627683..358e05e0b 100644 --- a/src/Orchard.Web/Modules/Orchard.SecureSocketsLayer/Services/SecureSocketsLayerService.cs +++ b/src/Orchard.Web/Modules/Orchard.SecureSocketsLayer/Services/SecureSocketsLayerService.cs @@ -99,6 +99,10 @@ namespace Orchard.SecureSocketsLayer.Services { var urlHelper = new UrlHelper(requestContext); var url = urlHelper.Action(actionName, controllerName, requestContext.RouteData); + if (String.IsNullOrWhiteSpace(url)) { + return false; + } + return IsRequestProtected( url, requestContext.HttpContext.Request.ApplicationPath, settings); } diff --git a/src/Orchard.Web/Modules/Orchard.SecureSocketsLayer/Views/EditorTemplates/Parts/SecureSocketsLayer.Settings.cshtml b/src/Orchard.Web/Modules/Orchard.SecureSocketsLayer/Views/EditorTemplates/Parts/SecureSocketsLayer.Settings.cshtml index 7ced91c1c..9879a163e 100644 --- a/src/Orchard.Web/Modules/Orchard.SecureSocketsLayer/Views/EditorTemplates/Parts/SecureSocketsLayer.Settings.cshtml +++ b/src/Orchard.Web/Modules/Orchard.SecureSocketsLayer/Views/EditorTemplates/Parts/SecureSocketsLayer.Settings.cshtml @@ -8,6 +8,16 @@ @Html.ValidationMessage("Enabled", "*")
+
+ + @Html.TextBoxFor(m => m.SecureHostName, new { @class = "textMedium" }) + @T("(Mandatory) The host name secured traffic should be redirected to (e.g. localhost:44300, secure.mydomain.com). Don't include the protocol or anything else than the host name. A port can be specified after a colon if necessary (e.g. secure.127-0-0-1.org.uk:4333).") +
+
+ + @Html.TextBoxFor(m => m.InsecureHostName, new { @class = "textMedium" }) + @T("(Mandatory) The host name non-secured traffic should be redirected to (e.g. localhost:30321, mydomain.com). Don't include the protocol or anything else than the host name. A port can be specified after a colon if necessary (e.g. dev.127-0-0-1.org.uk:4333).") +
@Html.EditorFor(m => m.SecureEverything) @@ -29,16 +39,6 @@
-
- - @Html.TextBoxFor(m => m.SecureHostName, new { @class = "textMedium" }) - @T("Provide the host name secure traffic should be redirected to (e.g. secure.mydomain.com). Don't include the protocol or anything else than the host name. A port can be specified after a colon if necessary (e.g. secure.127-0-0-1.org.uk:4333).") -
-
- - @Html.TextBoxFor(m => m.InsecureHostName, new { @class = "textMedium" }) - @T("Provide the host name non-secured traffic should be redirected to (e.g. mydomain.com). Don't include the protocol or anything else than the host name. A port can be specified after a colon if necessary (e.g. dev.127-0-0-1.org.uk:4333).") -
\ No newline at end of file