diff --git a/src/Orchard.Web/Modules/Orchard.SecureSocketsLayer/Filters/SecureSocketsLayersFilter.cs b/src/Orchard.Web/Modules/Orchard.SecureSocketsLayer/Filters/SecureSocketsLayersFilter.cs index 6c51f60d3..317c491d0 100644 --- a/src/Orchard.Web/Modules/Orchard.SecureSocketsLayer/Filters/SecureSocketsLayersFilter.cs +++ b/src/Orchard.Web/Modules/Orchard.SecureSocketsLayer/Filters/SecureSocketsLayersFilter.cs @@ -29,7 +29,7 @@ namespace Orchard.SecureSocketsLayer.Filters { var secure = (user != null && user.Identity.IsAuthenticated) || _sslService.ShouldBeSecure(filterContext); - + var usePermanentRedirect = settings.UsePermanentRedirect; var request = filterContext.HttpContext.Request; // redirect to a secured connection ? @@ -41,7 +41,7 @@ namespace Orchard.SecureSocketsLayer.Filters { filterContext.ActionDescriptor.ControllerDescriptor.ControllerName, filterContext.RequestContext.RouteData.Values)); - filterContext.Result = new RedirectResult(secureActionUrl); + filterContext.Result = new RedirectResult(secureActionUrl, usePermanentRedirect); return; } @@ -56,7 +56,7 @@ namespace Orchard.SecureSocketsLayer.Filters { filterContext.ActionDescriptor.ControllerDescriptor.ControllerName, filterContext.RequestContext.RouteData.Values)); - filterContext.Result = new RedirectResult(insecureActionUrl); + filterContext.Result = new RedirectResult(insecureActionUrl, usePermanentRedirect); } } @@ -67,4 +67,4 @@ namespace Orchard.SecureSocketsLayer.Filters { return url; } } -} \ No newline at end of file +} diff --git a/src/Orchard.Web/Modules/Orchard.SecureSocketsLayer/Models/SslSettingsPart.cs b/src/Orchard.Web/Modules/Orchard.SecureSocketsLayer/Models/SslSettingsPart.cs index 4d1f1b445..f377e8b7b 100644 --- a/src/Orchard.Web/Modules/Orchard.SecureSocketsLayer/Models/SslSettingsPart.cs +++ b/src/Orchard.Web/Modules/Orchard.SecureSocketsLayer/Models/SslSettingsPart.cs @@ -6,6 +6,7 @@ using Orchard.ContentManagement.FieldStorage.InfosetStorage; namespace Orchard.SecureSocketsLayer.Models { public class SslSettings { public bool Enabled { get; set; } + public bool UsePermanentRedirect { get; set; } public string Urls { get; set; } public bool SecureEverything { get; set; } public bool CustomEnabled { get; set; } @@ -37,6 +38,14 @@ namespace Orchard.SecureSocketsLayer.Models { set { this.As().Set("Enabled", value.ToString()); } } + public bool UsePermanentRedirect { + get { + var attributeValue = this.As().Get("UsePermanentRedirect"); + return !String.IsNullOrWhiteSpace(attributeValue) && Convert.ToBoolean(attributeValue); + } + set { this.As().Set("UsePermanentRedirect", value.ToString()); } + } + public bool CustomEnabled { get { var attributeValue = this.As().Get("CustomEnabled"); diff --git a/src/Orchard.Web/Modules/Orchard.SecureSocketsLayer/Services/SecureSocketsLayerService.cs b/src/Orchard.Web/Modules/Orchard.SecureSocketsLayer/Services/SecureSocketsLayerService.cs index a3e3ced50..6c94f9a1f 100644 --- a/src/Orchard.Web/Modules/Orchard.SecureSocketsLayer/Services/SecureSocketsLayerService.cs +++ b/src/Orchard.Web/Modules/Orchard.SecureSocketsLayer/Services/SecureSocketsLayerService.cs @@ -205,7 +205,8 @@ namespace Orchard.SecureSocketsLayer.Services { SecureEverything = settingsPart.SecureEverything, SecureHostName = settingsPart.SecureHostName, InsecureHostName = settingsPart.InsecureHostName, - Enabled = settingsPart.Enabled + Enabled = settingsPart.Enabled, + UsePermanentRedirect = settingsPart.UsePermanentRedirect }; }); } 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 c7aad106e..0a864e961 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 @@ -18,6 +18,11 @@ @Html.TextBoxFor(m => m.InsecureHostName, new { @class = "textMedium" }) @Html.Hint(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.UsePermanentRedirect) + + @Html.ValidationMessage("UsePermanentRedirect", "*") +
@Html.EditorFor(m => m.SecureEverything)