mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-07-15 23:37:44 +08:00
parent
e447561cfe
commit
d51418b2c1
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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<InfosetPart>().Set<SslSettingsPart>("Enabled", value.ToString()); }
|
||||
}
|
||||
|
||||
public bool UsePermanentRedirect {
|
||||
get {
|
||||
var attributeValue = this.As<InfosetPart>().Get<SslSettingsPart>("UsePermanentRedirect");
|
||||
return !String.IsNullOrWhiteSpace(attributeValue) && Convert.ToBoolean(attributeValue);
|
||||
}
|
||||
set { this.As<InfosetPart>().Set<SslSettingsPart>("UsePermanentRedirect", value.ToString()); }
|
||||
}
|
||||
|
||||
public bool CustomEnabled {
|
||||
get {
|
||||
var attributeValue = this.As<InfosetPart>().Get<SslSettingsPart>("CustomEnabled");
|
||||
|
@ -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
|
||||
};
|
||||
});
|
||||
}
|
||||
|
@ -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)."))
|
||||
</div>
|
||||
<div>
|
||||
@Html.EditorFor(m => m.UsePermanentRedirect)
|
||||
<label for="@Html.FieldIdFor(m => m.UsePermanentRedirect)" class="forcheckbox">@T("Enable Permanent redirection")</label>
|
||||
@Html.ValidationMessage("UsePermanentRedirect", "*")
|
||||
</div>
|
||||
<div>
|
||||
@Html.EditorFor(m => m.SecureEverything)
|
||||
<label for="@Html.FieldIdFor(m => m.SecureEverything)" class="forcheckbox">@T("Force SSL on all pages")</label>
|
||||
|
Loading…
Reference in New Issue
Block a user