mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Compare commits
16 Commits
feature/ca
...
azureauth
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1494fee906 | ||
|
|
6720b71cf3 | ||
|
|
0173250b46 | ||
|
|
e1f05626c4 | ||
|
|
25f3298e0c | ||
|
|
6f4c12a8a1 | ||
|
|
51d79955a1 | ||
|
|
e94738ce34 | ||
|
|
d32847bee1 | ||
|
|
c016a03b40 | ||
|
|
26129a7e77 | ||
|
|
8cd1778a80 | ||
|
|
89a84cd00f | ||
|
|
9110e93fca | ||
|
|
4df4e6fd12 | ||
|
|
dcdb47e543 |
@@ -31,7 +31,7 @@ We invite participation by the developer community in shaping the project’s di
|
||||
All our releases are available on our [Releases](https://github.com/OrchardCMS/Orchard/releases) page, and it's easy to [Install Orchard using the Web Platform Installer](http://docs.orchardproject.net/Documentation/Installing-Orchard) as well. We encourage interested developers to check out the source code on the Orchard GitHub site and get involved with the project.
|
||||
|
||||
* [Download the latest release](https://github.com/OrchardCMS/Orchard/releases)
|
||||
* [Feature roadmap](http://docs.orchardproject.net/Documentation/feature-roadmap)
|
||||
* [Feature roadmap](http://docs.orchardproject.net/Documentation/Feature-roadmap)
|
||||
* [Docs and designs/specs](http://www.orchardproject.net/docs)
|
||||
* [About us](http://www.orchardproject.net/about)
|
||||
* [Contact us](mailto:ofeedbk@microsoft.com)
|
||||
|
||||
@@ -27,6 +27,10 @@
|
||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
||||
@@ -18,6 +18,10 @@
|
||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
||||
@@ -1,4 +1,6 @@
|
||||
@{
|
||||
var propertyName = Model.PropertyName != null ? (string)Model.PropertyName : "Text";
|
||||
|
||||
var htmlAttributes = new Dictionary<string, object> {
|
||||
{"class", "text large"}
|
||||
};
|
||||
@@ -12,4 +14,4 @@
|
||||
}
|
||||
}
|
||||
|
||||
@Html.TextBox("Text", (string)Model.Text, htmlAttributes)
|
||||
@Html.TextBox(propertyName, (string)Model.Text, htmlAttributes)
|
||||
@@ -1,4 +1,6 @@
|
||||
@{
|
||||
var propertyName = Model.PropertyName != null ? (string)Model.PropertyName : "Text";
|
||||
|
||||
var htmlAttributes = new Dictionary<string, object> {
|
||||
{"class", "text small"}
|
||||
};
|
||||
@@ -12,4 +14,4 @@
|
||||
}
|
||||
}
|
||||
|
||||
@Html.TextBox("Text", (string)Model.Text, htmlAttributes)
|
||||
@Html.TextBox(propertyName, (string)Model.Text, htmlAttributes)
|
||||
@@ -1,4 +1,6 @@
|
||||
@{
|
||||
var propertyName = Model.PropertyName != null ? (string)Model.PropertyName : "Text";
|
||||
|
||||
var htmlAttributes = new Dictionary<string, object>();
|
||||
|
||||
if (Model.Required == true) {
|
||||
@@ -14,4 +16,4 @@
|
||||
}
|
||||
}
|
||||
|
||||
@Html.TextArea("Text", (string)Model.Text, 25, 80, htmlAttributes)
|
||||
@Html.TextArea(propertyName, (string)Model.Text, 25, 80, htmlAttributes)
|
||||
@@ -1,4 +1,6 @@
|
||||
@{
|
||||
var propertyName = Model.PropertyName != null ? (string)Model.PropertyName : "Text";
|
||||
|
||||
var htmlAttributes = new Dictionary<string, object> {
|
||||
{"class", "text medium"}
|
||||
};
|
||||
@@ -12,4 +14,4 @@
|
||||
}
|
||||
}
|
||||
|
||||
@Html.TextBox("Text", (string)Model.Text, htmlAttributes)
|
||||
@Html.TextBox(propertyName, (string)Model.Text, htmlAttributes)
|
||||
@@ -1,5 +1,7 @@
|
||||
@using Orchard.Utility.Extensions;
|
||||
@{
|
||||
var propertyName = Model.PropertyName != null ? (string)Model.PropertyName : "Text";
|
||||
|
||||
string editorFlavor = Model.EditorFlavor;
|
||||
|
||||
var htmlAttributes = new Dictionary<string, object> {
|
||||
@@ -19,4 +21,4 @@
|
||||
}
|
||||
}
|
||||
|
||||
@Html.TextArea("Text", (string)Model.Text, 25, 80, htmlAttributes)
|
||||
@Html.TextArea(propertyName, (string)Model.Text, 25, 80, htmlAttributes)
|
||||
@@ -22,7 +22,7 @@
|
||||
<fieldset>
|
||||
@Html.LabelFor(m => m.EnablePositioning, @T("Enable drag and drop"))
|
||||
@Html.EditorFor(m => m.EnablePositioning)
|
||||
<span class="hint">@T("Check this option to enable manual repositioning of items using. If not set, this option will be configurable on the list content item itself.")</span>
|
||||
<span class="hint">@T("Check this option to enable manual repositioning of items using drag and drop. If not set, this option will be configurable on the list content item itself.")</span>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
@Html.LabelFor(m => m.AdminListViewName, @T("List View"))
|
||||
@@ -45,4 +45,4 @@
|
||||
<span class="hint">@T("Select zero or more content types that this content type supports. Selecting zero content types means the list can contain any content type. Only types with the Containable part can be contained in a list.")</span>
|
||||
</div>
|
||||
</fieldset>
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
@Html.SelectOption((ContentsOrder)Model.Options.OrderBy, ContentsOrder.Modified, T("recently modified").ToString())
|
||||
@Html.SelectOption((ContentsOrder)Model.Options.OrderBy, ContentsOrder.Published, T("recently published").ToString())
|
||||
</select>
|
||||
<label for="contentResults" class="bulk-order">@T("Filter by")</label>
|
||||
<label for="contentResults" class="bulk-filter">@T("Filter by")</label>
|
||||
<select id="contentResults" name="Options.ContentsStatus">
|
||||
@Html.SelectOption((ContentsStatus)Model.Options.ContentsStatus, ContentsStatus.Owner, T("owned by me").ToString())
|
||||
@Html.SelectOption((ContentsStatus)Model.Options.ContentsStatus, ContentsStatus.Latest, T("latest").ToString())
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
using System;
|
||||
using System;
|
||||
using Orchard.Commands;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Aspects;
|
||||
using Orchard.Core.Common.Models;
|
||||
using Orchard.Core.Navigation.Models;
|
||||
using Orchard.Core.Navigation.Services;
|
||||
using Orchard.Security;
|
||||
@@ -15,7 +16,7 @@ namespace Orchard.Core.Navigation.Commands {
|
||||
private readonly IMembershipService _membershipService;
|
||||
|
||||
public MenuCommands(
|
||||
IContentManager contentManager,
|
||||
IContentManager contentManager,
|
||||
IMenuService menuService,
|
||||
ISiteService siteService,
|
||||
IMembershipService membershipService) {
|
||||
@@ -27,7 +28,10 @@ namespace Orchard.Core.Navigation.Commands {
|
||||
|
||||
[OrchardSwitch]
|
||||
public string MenuPosition { get; set; }
|
||||
|
||||
|
||||
[OrchardSwitch]
|
||||
public string Identity { get; set; }
|
||||
|
||||
[OrchardSwitch]
|
||||
public string Owner { get; set; }
|
||||
|
||||
@@ -41,7 +45,7 @@ namespace Orchard.Core.Navigation.Commands {
|
||||
public string MenuName { get; set; }
|
||||
|
||||
[CommandName("menuitem create")]
|
||||
[CommandHelp("menuitem create /MenuPosition:<position> /MenuText:<text> /Url:<url> /MenuName:<name> [/Owner:<username>] \r\n\t" + "Creates a new menu item")]
|
||||
[CommandHelp("menuitem create /MenuPosition:<position> /MenuText:<text> /Url:<url> /MenuName:<name> [/Owner:<username>]\r\n\t" + "Creates a new menu item")]
|
||||
[OrchardSwitches("MenuPosition,MenuText,Url,MenuName,Owner")]
|
||||
public void Create() {
|
||||
// flushes before doing a query in case a previous command created the menu
|
||||
@@ -75,17 +79,20 @@ namespace Orchard.Core.Navigation.Commands {
|
||||
}
|
||||
|
||||
[CommandName("menu create")]
|
||||
[CommandHelp("menu create /MenuName:<name>\r\n\t" + "Creates a new menu")]
|
||||
[OrchardSwitches("MenuName")]
|
||||
[CommandHelp("menu create /MenuName:<name> [/Identity:<identity>] \r\n\t" + "Creates a new menu")]
|
||||
[OrchardSwitches("MenuName,Identity")]
|
||||
public void CreateMenu() {
|
||||
if (string.IsNullOrWhiteSpace(MenuName)) {
|
||||
Context.Output.WriteLine(T("Menu name can't be empty.").Text);
|
||||
return;
|
||||
}
|
||||
|
||||
_menuService.Create(MenuName);
|
||||
var menuItem = _menuService.Create(MenuName);
|
||||
if (menuItem.Has<IdentityPart>() && !String.IsNullOrEmpty(Identity)) {
|
||||
menuItem.As<IdentityPart>().Identifier = Identity;
|
||||
}
|
||||
|
||||
Context.Output.WriteLine(T("Menu created successfully.").Text);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -177,5 +177,13 @@ namespace Orchard.Core.Navigation {
|
||||
|
||||
return 6;
|
||||
}
|
||||
|
||||
public int UpdateFrom6() {
|
||||
ContentDefinitionManager.AlterTypeDefinition("ShapeMenuItem", cfg => cfg
|
||||
.WithIdentity()
|
||||
);
|
||||
|
||||
return 7;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,27 +25,27 @@
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
@Html.EditorFor(m => m.Breadcrumb)
|
||||
@Html.EditorFor(m => m.Breadcrumb)
|
||||
<label class="forcheckbox" for="@Html.FieldIdFor(m => m.Breadcrumb)">@T("Display as Breadcrumb")</label>
|
||||
<span class="hint">@T("Check to render the path to the current content item.")</span>
|
||||
</fieldset>
|
||||
|
||||
|
||||
<div data-controllerid="@Html.FieldIdFor(m => m.Breadcrumb)">
|
||||
<fieldset>
|
||||
@Html.EditorFor(m => m.AddHomePage)
|
||||
@Html.EditorFor(m => m.AddHomePage)
|
||||
<label class="forcheckbox" for="@Html.FieldIdFor(m => m.AddHomePage)">@T("Add the home page as the first element")</label>
|
||||
<span class="hint">@T("Check to render the home page as the first element of the breadcrumb.")</span>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
@Html.EditorFor(m => m.AddCurrentPage)
|
||||
@Html.EditorFor(m => m.AddCurrentPage)
|
||||
<label class="forcheckbox" for="@Html.FieldIdFor(m => m.AddCurrentPage)">@T("Add the current content item as the last element")</label>
|
||||
<span class="hint">@T("Check to render the current content item as the last element.")</span>
|
||||
</fieldset>
|
||||
</div>
|
||||
|
||||
<fieldset>
|
||||
@Html.EditorFor(m => m.ShowFullMenu)
|
||||
@Html.EditorFor(m => m.ShowFullMenu)
|
||||
<label class="forcheckbox" for="@Html.FieldIdFor(m => m.ShowFullMenu)">@T("No filter on selected page")</label>
|
||||
<span class="hint">@T("Check for the menu to be display without filtering the selected current page.")</span>
|
||||
</fieldset>
|
||||
<span class="hint">@T("Check for the menu to be displayed without filtering the selected current page.")</span>
|
||||
</fieldset>
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
@using Orchard.Environment.Descriptor.Models
|
||||
|
||||
@{
|
||||
var propertyName = Model.PropertyName != null ? (string)Model.PropertyName : "Text";
|
||||
|
||||
Script.Require("OrchardMarkdown");
|
||||
Style.Require("OrchardMarkdown");
|
||||
|
||||
@@ -35,7 +37,7 @@
|
||||
<div class="wmd-innerbox">
|
||||
<div class="wmd-editor-box">
|
||||
<div id="wmd-button-bar-@idPostfix" class="wmd-button-bar"></div>
|
||||
@Html.TextArea("Text", (string)Model.Text, 25, 80, textAreaAttributes)
|
||||
@Html.TextArea(propertyName, (string)Model.Text, 25, 80, textAreaAttributes)
|
||||
</div>
|
||||
<div class="wmd-preview-box">
|
||||
<div id="wmd-preview-@idPostfix" class="wmd-panel wmd-preview"></div>
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
[
|
||||
{
|
||||
"inputs": [ "Assets/Styles.less" ],
|
||||
"output": "Styles/Styles.css"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,13 @@
|
||||
namespace Orchard.Azure.Authentication.Constants {
|
||||
public class DefaultAzureSettings {
|
||||
public static readonly string Tenant = "mydirectory.onmicrosoft.com";
|
||||
public static readonly string ClientId = "MyClientId";
|
||||
public static readonly string ADInstance = "https://login.microsoftonline.com/{0}";
|
||||
public static readonly string LogoutRedirectUri = "http://localhost:30321/OrchardLocal/";
|
||||
public static readonly bool BearerAuthEnabled = false;
|
||||
public static readonly bool SSLEnabled = false;
|
||||
public static readonly bool AzureWebSiteProtectionEnabled = false;
|
||||
public static readonly string GraphiApiUri = "https://graph.windows.net";
|
||||
public static readonly string GraphApiKey = "XSpN3xxGE7KgjLF/3lk2PBz98eAQpIMwUQUvoB/bZXs=";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
using System;
|
||||
using Microsoft.Owin.Security;
|
||||
using Microsoft.Owin.Security.Cookies;
|
||||
using Microsoft.Owin.Security.OpenIdConnect;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.Security;
|
||||
using Orchard.Themes;
|
||||
using System.Web;
|
||||
using System.Web.Configuration;
|
||||
using System.Web.Mvc;
|
||||
using Orchard.Azure.Authentication.Services;
|
||||
using Orchard.Logging;
|
||||
|
||||
namespace Orchard.Azure.Authentication.Controllers {
|
||||
[Themed]
|
||||
[OrchardSuppressDependency("Orchard.Users.Controllers.AccountController")]
|
||||
public class AccountController : Controller {
|
||||
public ILogger Logger { get; set; }
|
||||
|
||||
private readonly IAzureGraphiApiService _graphiApiService;
|
||||
private readonly IAzureRolesPersistence _azureRolesPersistence;
|
||||
|
||||
public AccountController(IAzureGraphiApiService graphiApiService, IAzureRolesPersistence azureRolesPersistence) {
|
||||
Logger = NullLogger.Instance;
|
||||
_graphiApiService = graphiApiService;
|
||||
_azureRolesPersistence = azureRolesPersistence;
|
||||
}
|
||||
public void LogOn() {
|
||||
if (Request.IsAuthenticated) {
|
||||
return; //TODO: redirect to home if we can?
|
||||
}
|
||||
|
||||
var redirectUri = Url.Content("~/users/account/logoncallback");
|
||||
|
||||
HttpContext.GetOwinContext().Authentication.Challenge(new AuthenticationProperties {RedirectUri = redirectUri},
|
||||
OpenIdConnectAuthenticationDefaults.AuthenticationType);
|
||||
}
|
||||
|
||||
public void LogOff() {
|
||||
HttpContext.GetOwinContext().Authentication.SignOut(
|
||||
OpenIdConnectAuthenticationDefaults.AuthenticationType, CookieAuthenticationDefaults.AuthenticationType); //OpenID Connect sign-out request.
|
||||
}
|
||||
|
||||
public ActionResult LogonCallback() {
|
||||
var userName = HttpContext.GetOwinContext().Authentication.User.Identity.Name.Trim();
|
||||
|
||||
try {
|
||||
var groups = _graphiApiService.GetUserGroups(userName);
|
||||
_azureRolesPersistence.SyncAzureGroupsToOrchardRoles(userName, groups);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
Logger.Error(ex.Message, ex);
|
||||
}
|
||||
|
||||
return Redirect(Url.Content("~/"));
|
||||
}
|
||||
|
||||
[AlwaysAccessible]
|
||||
public ActionResult AccessDenied() {
|
||||
return View();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Drivers;
|
||||
using Orchard.Azure.Authentication.Models;
|
||||
|
||||
namespace Orchard.Azure.Authentication.Drivers {
|
||||
public class AzureSettingsPartDriver : ContentPartDriver<AzureSettingsPart> {
|
||||
protected override string Prefix {
|
||||
get { return "AzureSettings"; }
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(AzureSettingsPart part, dynamic shapeHelper) {
|
||||
return ContentShape("Parts_AzureSettings_Edit", () =>
|
||||
shapeHelper.EditorTemplate(TemplateName: "Parts/AzureSettings", Model: part, Prefix: Prefix)).OnGroup("Azure");
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(AzureSettingsPart part, IUpdateModel updater, dynamic shapeHelper) {
|
||||
updater.TryUpdateModel(part, Prefix, null, null);
|
||||
return Editor(part, shapeHelper);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using Orchard.ContentManagement.Handlers;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Data;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Azure.Authentication.Models;
|
||||
|
||||
namespace Orchard.Azure.Authentication.Handlers {
|
||||
public class AzureSettingsPartHandler : ContentHandler {
|
||||
public Localizer T { get; set; }
|
||||
|
||||
public AzureSettingsPartHandler() {
|
||||
T= NullLocalizer.Instance;
|
||||
Filters.Add(new ActivatingFilter<AzureSettingsPart>("Site"));
|
||||
Filters.Add(new TemplateFilterForPart<AzureSettingsPart>("AzureSettings", "Parts/AzureSettings", "Azure Authentication"));
|
||||
}
|
||||
|
||||
protected override void GetItemMetadata(GetContentItemMetadataContext context) {
|
||||
if (context.ContentItem.ContentType != "Site") {
|
||||
return;
|
||||
}
|
||||
|
||||
base.GetItemMetadata(context);
|
||||
context.Metadata.EditorGroupInfo.Add(new GroupInfo(T("Azure Authentication")));
|
||||
}
|
||||
}
|
||||
}
|
||||
201
src/Orchard.Web/Modules/Orchard.Azure.Authentication/LICENSE.txt
Normal file
201
src/Orchard.Web/Modules/Orchard.Azure.Authentication/LICENSE.txt
Normal file
@@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "{}"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright 2015 Radio Systems Corporation
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
@@ -0,0 +1,55 @@
|
||||
using Orchard.ContentManagement;
|
||||
|
||||
namespace Orchard.Azure.Authentication.Models {
|
||||
public class AzureSettingsPart : ContentPart{
|
||||
public string Tenant {
|
||||
get { return this.Retrieve(x => x.Tenant); }
|
||||
set { this.Store(x => x.Tenant, value); }
|
||||
}
|
||||
|
||||
public string ADInstance {
|
||||
get { return this.Retrieve(x => x.ADInstance); }
|
||||
set { this.Store(x => x.ADInstance, value); }
|
||||
}
|
||||
|
||||
public string ClientId {
|
||||
get { return this.Retrieve(x => x.ClientId); }
|
||||
set { this.Store(x => x.ClientId, value); }
|
||||
}
|
||||
|
||||
public string AppName {
|
||||
get { return this.Retrieve(x => x.AppName); }
|
||||
set { this.Store(x => x.AppName, value); }
|
||||
}
|
||||
|
||||
public string LogoutRedirectUri {
|
||||
get { return this.Retrieve(x => x.LogoutRedirectUri); }
|
||||
set { this.Store(x => x.LogoutRedirectUri, value); }
|
||||
}
|
||||
|
||||
public bool BearerAuthEnabled {
|
||||
get { return this.Retrieve(x => x.BearerAuthEnabled); }
|
||||
set { this.Store(x => x.BearerAuthEnabled, value); }
|
||||
}
|
||||
|
||||
public bool SSLEnabled {
|
||||
get { return this.Retrieve(x => x.SSLEnabled); }
|
||||
set { this.Store(x => x.SSLEnabled, value); }
|
||||
}
|
||||
|
||||
public bool AzureWebSiteProtectionEnabled {
|
||||
get { return this.Retrieve(x => x.AzureWebSiteProtectionEnabled); }
|
||||
set { this.Store(x => x.AzureWebSiteProtectionEnabled, value); }
|
||||
}
|
||||
|
||||
public string GraphApiUrl {
|
||||
get { return this.Retrieve(x => x.GraphApiUrl); }
|
||||
set { this.Store(x => x.GraphApiUrl, value); }
|
||||
}
|
||||
|
||||
public bool UseAzureGraphApi {
|
||||
get { return this.Retrieve(x => x.UseAzureGraphApi); }
|
||||
set { this.Store(x => x.UseAzureGraphApi, value); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
Name: Orchard.Azure.Authentication
|
||||
AntiForgery: enabled
|
||||
Author: Radio Systems Corp.
|
||||
Website: http://orchardproject.net
|
||||
Version: 1.0
|
||||
OrchardVersion: 1.9.2
|
||||
Description: Description for the module
|
||||
Features:
|
||||
Orchard.Azure.Authentication:
|
||||
Description: Provides Azure Active Directory authentication.
|
||||
Category: Authentication
|
||||
|
||||
@@ -0,0 +1,286 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>9.0.30729</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{60D63D66-E88E-4D07-82EE-C1561903A73E}</ProjectGuid>
|
||||
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Orchard.Azure.Authentication</RootNamespace>
|
||||
<AssemblyName>Orchard.Azure.Authentication</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||
<MvcBuildViews>false</MvcBuildViews>
|
||||
<FileUpgradeFlags>
|
||||
</FileUpgradeFlags>
|
||||
<OldToolsVersion>4.0</OldToolsVersion>
|
||||
<UpgradeBackupLocation />
|
||||
<TargetFrameworkProfile />
|
||||
<UseIISExpress>false</UseIISExpress>
|
||||
<IISExpressSSLPort />
|
||||
<IISExpressAnonymousAuthentication />
|
||||
<IISExpressWindowsAuthentication />
|
||||
<IISExpressUseClassicPipelineMode />
|
||||
<UseGlobalApplicationHostFile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodeAnalysisRuleSet>..\..\..\OrchardBasicCorrectness.ruleset</CodeAnalysisRuleSet>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Iesi.Collections, Version=4.0.0.0, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\packages\Iesi.Collections.4.0.1.4000\lib\net40\Iesi.Collections.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Azure.ActiveDirectory.GraphClient, Version=2.1.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\packages\Microsoft.Azure.ActiveDirectory.GraphClient.2.1.0\lib\portable-net4+sl5+win+wpa+wp8\Microsoft.Azure.ActiveDirectory.GraphClient.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="Microsoft.Data.Edm, Version=5.6.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\packages\Microsoft.Data.Edm.5.6.4\lib\net40\Microsoft.Data.Edm.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Data.OData, Version=5.6.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\packages\Microsoft.Data.OData.5.6.4\lib\net40\Microsoft.Data.OData.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Data.Services.Client, Version=5.6.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\packages\Microsoft.Data.Services.Client.5.6.4\lib\net40\Microsoft.Data.Services.Client.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.IdentityModel.Clients.ActiveDirectory, Version=2.19.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.2.19.208020213\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms, Version=2.19.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.2.19.208020213\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.IdentityModel.Logging, Version=1.0.0.127, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\packages\Microsoft.IdentityModel.Logging.1.0.0\lib\net451\Microsoft.IdentityModel.Logging.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.IdentityModel.Protocol.Extensions, Version=1.0.2.33, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\packages\Microsoft.IdentityModel.Protocol.Extensions.1.0.2.206221351\lib\net45\Microsoft.IdentityModel.Protocol.Extensions.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.IdentityModel.Tokens, Version=5.0.0.127, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\packages\Microsoft.IdentityModel.Tokens.5.0.0\lib\net451\Microsoft.IdentityModel.Tokens.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Owin, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\packages\Microsoft.Owin.3.0.1\lib\net45\Microsoft.Owin.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Owin.Host.SystemWeb, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\packages\Microsoft.Owin.Host.SystemWeb.3.0.1\lib\net45\Microsoft.Owin.Host.SystemWeb.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Owin.Security, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\packages\Microsoft.Owin.Security.3.0.1\lib\net45\Microsoft.Owin.Security.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Owin.Security.ActiveDirectory, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\packages\Microsoft.Owin.Security.ActiveDirectory.3.0.1\lib\net45\Microsoft.Owin.Security.ActiveDirectory.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Owin.Security.Cookies, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\packages\Microsoft.Owin.Security.Cookies.3.0.1\lib\net45\Microsoft.Owin.Security.Cookies.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Owin.Security.Jwt, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\packages\Microsoft.Owin.Security.Jwt.3.0.1\lib\net45\Microsoft.Owin.Security.Jwt.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Owin.Security.OAuth, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\packages\Microsoft.Owin.Security.OAuth.3.0.1\lib\net45\Microsoft.Owin.Security.OAuth.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Owin.Security.OpenIdConnect, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\packages\Microsoft.Owin.Security.OpenIdConnect.3.0.1\lib\net45\Microsoft.Owin.Security.OpenIdConnect.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="NHibernate, Version=4.0.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\packages\NHibernate.4.0.1.4000\lib\net40\NHibernate.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Owin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f0ebd12fd5e55cc5, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\packages\Owin.1.0\lib\net40\Owin.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.ComponentModel.DataAnnotations">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="System.IdentityModel" />
|
||||
<Reference Include="System.IdentityModel.Tokens.Jwt, Version=5.0.0.127, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\packages\System.IdentityModel.Tokens.Jwt.5.0.0\lib\net451\System.IdentityModel.Tokens.Jwt.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Runtime.Serialization" />
|
||||
<Reference Include="System.Spatial, Version=5.6.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\packages\System.Spatial.5.6.4\lib\net40\System.Spatial.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.ApplicationServices" />
|
||||
<Reference Include="System.Web.DynamicData" />
|
||||
<Reference Include="System.Web.Entity" />
|
||||
<Reference Include="System.Web.Extensions" />
|
||||
<Reference Include="System.Web.Helpers, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.Helpers.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Web.Abstractions" />
|
||||
<Reference Include="System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\packages\Microsoft.AspNet.Mvc.5.2.3\lib\net45\System.Web.Mvc.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\packages\Microsoft.AspNet.Razor.3.2.3\lib\net45\System.Web.Razor.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Routing" />
|
||||
<Reference Include="System.Web.WebPages, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.WebPages.Deployment, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.Deployment.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.Razor.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Assets.json" />
|
||||
<Content Include="Web.config" />
|
||||
<Content Include="Scripts\Web.config" />
|
||||
<Content Include="Module.txt" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\Orchard\Orchard.Framework.csproj">
|
||||
<Project>{2D1D92BB-4555-4CBE-8D0E-63563D6CE4C6}</Project>
|
||||
<Name>Orchard.Framework</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\Core\Orchard.Core.csproj">
|
||||
<Project>{9916839C-39FC-4CEB-A5AF-89CA7E87119F}</Project>
|
||||
<Name>Orchard.Core</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Orchard.Roles\Orchard.Roles.csproj">
|
||||
<Project>{d10ad48f-407d-4db5-a328-173ec7cb010f}</Project>
|
||||
<Name>Orchard.Roles</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Orchard.Users\Orchard.Users.csproj">
|
||||
<Project>{79aed36e-abd0-4747-93d3-8722b042454b}</Project>
|
||||
<Name>Orchard.Users</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Constants\DefaultAzureSettings.cs" />
|
||||
<Compile Include="Controllers\AccountController.cs" />
|
||||
<Compile Include="Drivers\AzureSettingsPartDriver.cs" />
|
||||
<Compile Include="Handlers\AzureSettingsPartHandler.cs" />
|
||||
<Compile Include="Models\AzureSettingsPart.cs" />
|
||||
<Compile Include="OwinMiddlewares.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Routes.cs" />
|
||||
<Compile Include="Security\MachineKeyDataProtector.cs" />
|
||||
<Compile Include="Services\AzureActiveDirectoryService.cs" />
|
||||
<Compile Include="Services\AzureAuthenticationService.cs" />
|
||||
<Compile Include="Services\AzureGraphiApiService.cs" />
|
||||
<Compile Include="Services\AzureRolesPersistence.cs" />
|
||||
<Compile Include="Services\IAzureGraphiApiService.cs" />
|
||||
<Compile Include="Services\IAzureRolesPersistence.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="placement.info" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Views\EditorTemplates\Parts\AzureSettings.cshtml" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target> -->
|
||||
<Target Name="AfterBuild" DependsOnTargets="AfterBuildCompiler">
|
||||
<PropertyGroup>
|
||||
<AreasManifestDir>$(ProjectDir)\..\Manifests</AreasManifestDir>
|
||||
</PropertyGroup>
|
||||
<!-- If this is an area child project, uncomment the following line:
|
||||
<CreateAreaManifest AreaName="$(AssemblyName)" AreaType="Child" AreaPath="$(ProjectDir)" ManifestPath="$(AreasManifestDir)" ContentFiles="@(Content)" />
|
||||
-->
|
||||
<!-- If this is an area parent project, uncomment the following lines:
|
||||
<CreateAreaManifest AreaName="$(AssemblyName)" AreaType="Parent" AreaPath="$(ProjectDir)" ManifestPath="$(AreasManifestDir)" ContentFiles="@(Content)" />
|
||||
<CopyAreaManifests ManifestPath="$(AreasManifestDir)" CrossCopy="false" RenameViews="true" />
|
||||
-->
|
||||
</Target>
|
||||
<Target Name="AfterBuildCompiler" Condition="'$(MvcBuildViews)'=='true'">
|
||||
<AspNetCompiler VirtualPath="temp" PhysicalPath="$(ProjectDir)\..\$(ProjectName)" />
|
||||
</Target>
|
||||
<ProjectExtensions>
|
||||
<VisualStudio>
|
||||
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
|
||||
<WebProjectProperties>
|
||||
<UseIIS>False</UseIIS>
|
||||
<AutoAssignPort>True</AutoAssignPort>
|
||||
<DevelopmentServerPort>45979</DevelopmentServerPort>
|
||||
<DevelopmentServerVPath>/</DevelopmentServerVPath>
|
||||
<IISUrl>
|
||||
</IISUrl>
|
||||
<NTLMAuthentication>False</NTLMAuthentication>
|
||||
<UseCustomServer>True</UseCustomServer>
|
||||
<CustomServerUrl>http://orchard.codeplex.com</CustomServerUrl>
|
||||
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
|
||||
</WebProjectProperties>
|
||||
</FlavorProperties>
|
||||
</VisualStudio>
|
||||
</ProjectExtensions>
|
||||
</Project>
|
||||
@@ -0,0 +1,134 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Security.Claims;
|
||||
using System.Web.Helpers;
|
||||
using System.Web.WebPages;
|
||||
using Microsoft.IdentityModel.Clients.ActiveDirectory;
|
||||
using Microsoft.Owin.Security;
|
||||
using Microsoft.Owin.Security.Cookies;
|
||||
using Microsoft.Owin.Security.DataProtection;
|
||||
using Microsoft.Owin.Security.OpenIdConnect;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Logging;
|
||||
using Orchard.Owin;
|
||||
using Orchard.Settings;
|
||||
using Owin;
|
||||
using Orchard.Azure.Authentication.Constants;
|
||||
using Orchard.Azure.Authentication.Models;
|
||||
using Orchard.Azure.Authentication.Security;
|
||||
using Orchard.Azure.Authentication.Services;
|
||||
using AuthenticationContext = Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext;
|
||||
using LogLevel = Orchard.Logging.LogLevel;
|
||||
|
||||
namespace Orchard.Azure.Authentication {
|
||||
public class OwinMiddlewares : IOwinMiddlewareProvider {
|
||||
public ILogger Logger { get; set; }
|
||||
|
||||
private readonly string _azureClientId = DefaultAzureSettings.ClientId;
|
||||
private readonly string _azureTenant = DefaultAzureSettings.Tenant;
|
||||
private readonly string _logoutRedirectUri = DefaultAzureSettings.LogoutRedirectUri;
|
||||
private readonly string _azureAdInstance = DefaultAzureSettings.ADInstance;
|
||||
private readonly bool _azureWebSiteProtectionEnabled = DefaultAzureSettings.AzureWebSiteProtectionEnabled;
|
||||
private readonly string _azureGraphiApiUri = DefaultAzureSettings.GraphiApiUri;
|
||||
private readonly string _azureGraphApiKey = DefaultAzureSettings.GraphApiKey;
|
||||
|
||||
|
||||
public OwinMiddlewares(ISiteService siteService) {
|
||||
Logger = NullLogger.Instance;
|
||||
|
||||
try {
|
||||
var settings = siteService.GetSiteSettings().As<AzureSettingsPart>();
|
||||
|
||||
if (settings == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
_azureClientId = string.IsNullOrEmpty(settings.ClientId) ? _azureClientId : settings.ClientId;
|
||||
_azureTenant = string.IsNullOrEmpty(settings.Tenant) ? _azureTenant : settings.Tenant;
|
||||
_azureAdInstance = string.IsNullOrEmpty(settings.ADInstance) ? _azureAdInstance : settings.ADInstance;
|
||||
_logoutRedirectUri = string.IsNullOrEmpty(settings.LogoutRedirectUri) ? _logoutRedirectUri : settings.LogoutRedirectUri;
|
||||
_azureWebSiteProtectionEnabled = settings.AzureWebSiteProtectionEnabled;
|
||||
_azureGraphiApiUri = string.IsNullOrEmpty(settings.GraphApiUrl) ? _azureGraphiApiUri : settings.GraphApiUrl;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
Logger.Log(LogLevel.Debug, ex, "An error occured while accessing azure settings: {0}");
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<OwinMiddlewareRegistration> GetOwinMiddlewares() {
|
||||
var middlewares = new List<OwinMiddlewareRegistration>();
|
||||
|
||||
AntiForgeryConfig.UniqueClaimTypeIdentifier = ClaimTypes.NameIdentifier;
|
||||
|
||||
var openIdOptions = new OpenIdConnectAuthenticationOptions {
|
||||
ClientId = _azureClientId,
|
||||
Authority = string.Format(CultureInfo.InvariantCulture, _azureAdInstance, _azureTenant), // e.g. "https://login.windows.net/azurefridays.onmicrosoft.com/"
|
||||
PostLogoutRedirectUri = _logoutRedirectUri,
|
||||
Notifications = new OpenIdConnectAuthenticationNotifications()
|
||||
};
|
||||
|
||||
var cookieOptions = new CookieAuthenticationOptions();
|
||||
|
||||
if (_azureWebSiteProtectionEnabled) {
|
||||
middlewares.Add(new OwinMiddlewareRegistration {
|
||||
Priority = "9",
|
||||
Configure = app => { app.SetDataProtectionProvider(new MachineKeyProtectionProvider()); }
|
||||
});
|
||||
}
|
||||
|
||||
middlewares.Add(new OwinMiddlewareRegistration {
|
||||
Priority = "10",
|
||||
Configure = app => {
|
||||
app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
|
||||
|
||||
app.UseCookieAuthentication(cookieOptions);
|
||||
|
||||
app.UseOpenIdConnectAuthentication(openIdOptions);
|
||||
}
|
||||
});
|
||||
|
||||
middlewares.Add(new OwinMiddlewareRegistration {
|
||||
Priority = "11",
|
||||
Configure = app => app.Use(async (context, next) => {
|
||||
try {
|
||||
if (AzureActiveDirectoryService.token == null && AzureActiveDirectoryService.token.IsEmpty()) {
|
||||
RegenerateAzureGraphApiToken();
|
||||
}
|
||||
else {
|
||||
if (DateTimeOffset.Compare(DateTimeOffset.UtcNow, AzureActiveDirectoryService.tokenExpiresOn) > 0) {
|
||||
RegenerateAzureGraphApiToken();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
Logger.Log(LogLevel.Error, ex, "An error occured generating azure api credential {0}", ex.Message);
|
||||
}
|
||||
|
||||
await next.Invoke();
|
||||
})
|
||||
});
|
||||
|
||||
return middlewares;
|
||||
}
|
||||
|
||||
private void RegenerateAzureGraphApiToken() {
|
||||
var result = GetAuthContext().AcquireToken(_azureGraphiApiUri, GetClientCredential());
|
||||
|
||||
AzureActiveDirectoryService.tokenExpiresOn = result.ExpiresOn;
|
||||
AzureActiveDirectoryService.token = result.AccessToken;
|
||||
AzureActiveDirectoryService.azureGraphApiUri = _azureGraphiApiUri;
|
||||
AzureActiveDirectoryService.azureTenant = _azureTenant;
|
||||
}
|
||||
|
||||
private ClientCredential GetClientCredential() {
|
||||
return new ClientCredential(_azureClientId, _azureGraphApiKey);
|
||||
}
|
||||
|
||||
private AuthenticationContext GetAuthContext() {
|
||||
var authority = string.Format(CultureInfo.InvariantCulture, _azureAdInstance, _azureTenant);
|
||||
|
||||
return new AuthenticationContext(authority, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("Orchard.Azure.Authentication")]
|
||||
[assembly: AssemblyDescription("Orchard module that enables authentication with Windows Azure Active Directory")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("Orchard.Azure.Authentication")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2015")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("ff308bcd-8cf0-4103-b8aa-f7444985ca56")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
@@ -0,0 +1,15 @@
|
||||
# Orchard Azure Authentication Module
|
||||
|
||||
Orchard Azure Authentication is a module that enables Azure Authentication to Orchard using Azure Active Directory and OpenID connect. The module overrides the default login and integrates into the standard pipeline for Orchard.
|
||||
|
||||
## How to use
|
||||
|
||||
1. If you don't have an Azure Active Directory, get more info [here](https://azure.microsoft.com/en-us/documentation/articles/active-directory-whatis/). Create an application in Azure that will correspond to your Orchard instance. The settings you will need to configure Orchard Azure Active Directory Authentication will be on the configure tab of the created application.
|
||||
2. Before enabling the module, your must add an admin user to Orchard via the Orchard admin. Ensure that the user name matches the Azure Active Directory user name for the user you wish to have admin privileges.
|
||||
3. After enabling the module, before navigating away from the admin, go to site settings under the **Azure Authentication** group. Fill in the information from your Azure Active Directory. Tenant, AppName, and ClientId must be set. Other fields can be left as defaults.
|
||||
4. You will have to restart your Orchard site for the new settings to take effect.
|
||||
5. Navigate to the Orchard home screen. Clear site cookies, and watch Azure Authentication take over!
|
||||
|
||||
## License
|
||||
|
||||
This module is licensed under the Apache 2.0 license, a copy is included in the repository.
|
||||
@@ -0,0 +1,32 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Routing;
|
||||
using Orchard.Mvc.Routes;
|
||||
|
||||
namespace Orchard.Azure.Authentication {
|
||||
public class Routes : IRouteProvider {
|
||||
public IEnumerable<RouteDescriptor> GetRoutes() {
|
||||
return new[] {
|
||||
new RouteDescriptor {
|
||||
Route = new Route(
|
||||
"Users/Account/{action}",
|
||||
new RouteValueDictionary {
|
||||
{"area", "Orchard.Azure.Authentication"},
|
||||
{"controller", "Account"}
|
||||
},
|
||||
new RouteValueDictionary(),
|
||||
new RouteValueDictionary {
|
||||
{"area", "Orchard.Azure.Authentication"}
|
||||
},
|
||||
new MvcRouteHandler())
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public void GetRoutes(ICollection<RouteDescriptor> routes) {
|
||||
foreach (var route in GetRoutes()) {
|
||||
routes.Add(route);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<system.webServer>
|
||||
<staticContent>
|
||||
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="7.00:00:00" />
|
||||
</staticContent>
|
||||
|
||||
<handlers accessPolicy="Script,Read">
|
||||
<!--
|
||||
iis7 - for any request to a file exists on disk, return it via native http module.
|
||||
accessPolicy 'Script' is to allow for a managed 404 page.
|
||||
-->
|
||||
<add name="StaticFile" path="*" verb="*" modules="StaticFileModule" preCondition="integratedMode" resourceType="File" requireAccess="Read" />
|
||||
</handlers>
|
||||
</system.webServer>
|
||||
</configuration>
|
||||
@@ -0,0 +1,26 @@
|
||||
using System.Web.Security;
|
||||
using Microsoft.Owin.Security.DataProtection;
|
||||
|
||||
namespace Orchard.Azure.Authentication.Security {
|
||||
public class MachineKeyProtectionProvider : IDataProtectionProvider {
|
||||
public IDataProtector Create(params string[] purposes) {
|
||||
return new MachineKeyDataProtector(purposes);
|
||||
}
|
||||
}
|
||||
|
||||
public class MachineKeyDataProtector : IDataProtector {
|
||||
private readonly string[] _purposes;
|
||||
|
||||
public MachineKeyDataProtector(string[] purposes) {
|
||||
_purposes = purposes;
|
||||
}
|
||||
|
||||
public byte[] Protect(byte[] userData) {
|
||||
return MachineKey.Protect(userData, _purposes);
|
||||
}
|
||||
|
||||
public byte[] Unprotect(byte[] protectedData) {
|
||||
return MachineKey.Unprotect(protectedData, _purposes);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web.WebPages;
|
||||
using Microsoft.Azure.ActiveDirectory.GraphClient;
|
||||
using Orchard.Azure.Authentication.Constants;
|
||||
|
||||
namespace Orchard.Azure.Authentication.Services {
|
||||
public class AzureActiveDirectoryService {
|
||||
public static string token;
|
||||
public static DateTimeOffset tokenExpiresOn;
|
||||
public static string azureGraphApiUri = DefaultAzureSettings.GraphiApiUri;
|
||||
public static string azureTenant = DefaultAzureSettings.Tenant;
|
||||
|
||||
public static async Task<string> AcquireTokenAsync() {
|
||||
if (token == null || token.IsEmpty()) {
|
||||
throw new Exception("Authorization Required.");
|
||||
}
|
||||
return token;
|
||||
}
|
||||
|
||||
public static ActiveDirectoryClient GetActiveDirectoryClient() {
|
||||
var baseServiceUri = new Uri("https://graph.windows.net/");
|
||||
|
||||
var activeDirectoryClient = new ActiveDirectoryClient(new Uri(baseServiceUri, azureTenant),
|
||||
async () => await AcquireTokenAsync());
|
||||
|
||||
return activeDirectoryClient;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
using System.Web;
|
||||
using System.Web.Security;
|
||||
using Orchard.Mvc;
|
||||
using Orchard.Security;
|
||||
|
||||
namespace Orchard.Azure.Authentication.Services {
|
||||
public class AzureAuthenticationService : IAuthenticationService {
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
private readonly IMembershipService _membershipService;
|
||||
private IUser _localAuthenticationUser;
|
||||
|
||||
public AzureAuthenticationService(IHttpContextAccessor httpContextAccessor, IMembershipService membershipService) {
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
_membershipService = membershipService;
|
||||
}
|
||||
|
||||
public void SignIn(IUser user, bool createPersistentCookie) {}
|
||||
|
||||
public void SignOut() {}
|
||||
|
||||
public void SetAuthenticatedUserForRequest(IUser user) { }
|
||||
|
||||
public IUser GetAuthenticatedUser() {
|
||||
var azureUser = _httpContextAccessor.Current().GetOwinContext().Authentication.User;
|
||||
|
||||
if (!azureUser.Identity.IsAuthenticated) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// In memory caching of sorts since this method gets called many times per request
|
||||
if (_localAuthenticationUser != null) {
|
||||
return _localAuthenticationUser;
|
||||
}
|
||||
|
||||
var userName = azureUser.Identity.Name.Trim();
|
||||
|
||||
//Get the local user, if local user account doesn't exist, create it
|
||||
var localUser = _membershipService.GetUser(userName) ?? _membershipService.CreateUser(new CreateUserParams(
|
||||
userName, Membership.GeneratePassword(16, 1), userName, string.Empty, string.Empty, true
|
||||
));
|
||||
|
||||
return _localAuthenticationUser = localUser;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using Microsoft.Azure.ActiveDirectory.GraphClient;
|
||||
|
||||
namespace Orchard.Azure.Authentication.Services {
|
||||
public class AzureGraphiApiService : IAzureGraphiApiService {
|
||||
private readonly ActiveDirectoryClient _client;
|
||||
|
||||
public AzureGraphiApiService() {
|
||||
_client = AzureActiveDirectoryService.GetActiveDirectoryClient();
|
||||
}
|
||||
|
||||
public IUser GetUser(string userName) {
|
||||
var azureUser = _client.Users.Where(x => x.UserPrincipalName == userName)
|
||||
.ExecuteAsync().Result.CurrentPage.FirstOrDefault();
|
||||
return azureUser;
|
||||
}
|
||||
|
||||
public IList<Group> GetUserGroups(string userName) {
|
||||
var user = GetUser(userName);
|
||||
var userFetcher = (IUserFetcher) user;
|
||||
var groups = userFetcher.MemberOf.ExecuteAsync()
|
||||
.Result.CurrentPage.Select(x => x as Group).ToList();
|
||||
groups.RemoveAll(x => x == null);
|
||||
return groups;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.Azure.ActiveDirectory.GraphClient;
|
||||
using NHibernate;
|
||||
using Orchard.Data;
|
||||
using Orchard.Roles.Models;
|
||||
using Orchard.Roles.Services;
|
||||
using Orchard.Security;
|
||||
|
||||
namespace Orchard.Azure.Authentication.Services {
|
||||
public class AzureRolesPersistence : IAzureRolesPersistence {
|
||||
private readonly IRoleService _roleService;
|
||||
private readonly IMembershipService _membershipService;
|
||||
private readonly ISession _session;
|
||||
|
||||
public AzureRolesPersistence(IRoleService roleService, IMembershipService membershipService,
|
||||
ITransactionManager transactionManager) {
|
||||
_roleService = roleService;
|
||||
_membershipService = membershipService;
|
||||
_session = transactionManager.GetSession();
|
||||
}
|
||||
|
||||
public void SyncAzureGroupsToOrchardRoles(string userName, IList<Group> azureGroups) {
|
||||
var user = _membershipService.GetUser(userName);
|
||||
|
||||
var matchingOrchardRoles = azureGroups.Select(@group => _roleService.GetRoleByName(@group.DisplayName))
|
||||
.Where(orchardRole => orchardRole != null).ToList();
|
||||
|
||||
foreach (var role in matchingOrchardRoles) {
|
||||
var existingUserRole = _session.QueryOver<UserRolesPartRecord>()
|
||||
.Where(x => x.UserId == user.Id).And(x => x.Role.Id == role.Id).List().FirstOrDefault();
|
||||
|
||||
if (existingUserRole == null) {
|
||||
_session.SaveOrUpdate(new UserRolesPartRecord {
|
||||
Role = role,
|
||||
UserId = user.Id
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.Azure.ActiveDirectory.GraphClient;
|
||||
|
||||
namespace Orchard.Azure.Authentication.Services {
|
||||
public interface IAzureGraphiApiService : IDependency {
|
||||
IUser GetUser(string userName);
|
||||
IList<Group> GetUserGroups(string userObjectId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.Azure.ActiveDirectory.GraphClient;
|
||||
|
||||
namespace Orchard.Azure.Authentication.Services {
|
||||
public interface IAzureRolesPersistence : IDependency {
|
||||
void SyncAzureGroupsToOrchardRoles(string userName, IList<Group> azureGroups);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
@model Orchard.Azure.Authentication.Models.AzureSettingsPart
|
||||
|
||||
<fieldset>
|
||||
<legend>Azure Active Directory Settings</legend>
|
||||
@Html.LabelFor(m => m.Tenant, T("Tenant"))
|
||||
@Html.TextBoxFor(m => m.Tenant)
|
||||
<span class="hint">@T("Azure Active Directory tenant (e.g. mysite.onmicrosoft.com)")</span>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
@Html.LabelFor(m => m.ADInstance, T("Active Directory Instance"))
|
||||
@Html.TextBoxFor(m => m.ADInstance)
|
||||
<span class="hint">@T("Default instance is https://login.microsoftonline.com/{your-tenant-name}")</span>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
@Html.LabelFor(m => m.ClientId)
|
||||
@Html.TextBoxFor(m => m.ClientId)
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
@Html.LabelFor(m => m.AppName)
|
||||
@Html.TextBoxFor(m => m.AppName)
|
||||
<span class="hint">@T("Application name you wish to give active directly login rights to")</span>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
@Html.LabelFor(m => m.LogoutRedirectUri, T("Logout Redirect"))
|
||||
@Html.TextBoxFor(m => m.LogoutRedirectUri)
|
||||
<span class="hint">@T("Redirect url after azure logout, default is http://localhost:30321/OrchardLocal/")</span>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
@Html.LabelFor(m => m.BearerAuthEnabled, T("Enable Bearer Token Authentication"))
|
||||
@Html.CheckBoxFor(m => m.BearerAuthEnabled)
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
@Html.LabelFor(m => m.SSLEnabled, T("Use SSL Protocol for valid audience"))
|
||||
@Html.CheckBoxFor(m => m.SSLEnabled)
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
@Html.LabelFor(m => m.AzureWebSiteProtectionEnabled, T("Enable Machine Key Data Protection for Azure Web Site"))
|
||||
@Html.CheckBoxFor(m => m.AzureWebSiteProtectionEnabled)
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
@Html.LabelFor(m => m.GraphApiUrl)
|
||||
@Html.TextBoxFor(m => m.GraphApiUrl)
|
||||
<span class="hint">@T("Typically https://graph.windows.net")</span>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
@Html.LabelFor(m => m.UseAzureGraphApi)
|
||||
@Html.CheckBoxFor(m => m.UseAzureGraphApi)
|
||||
<span class="hint">@T("Check this box to enable syncing Orchard Role membership to Azure Graph API Group Membership. This module will not create new Orchard Roles for you, but it will sync up user membership of existing Orchard Roles with AD Group membership for Role names that match a group name")</span>
|
||||
</fieldset>
|
||||
@@ -0,0 +1,93 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<configSections>
|
||||
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
|
||||
<remove name="host" />
|
||||
<remove name="pages" />
|
||||
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
|
||||
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
|
||||
</sectionGroup>
|
||||
</configSections>
|
||||
<system.web.webPages.razor>
|
||||
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.3, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
|
||||
<pages pageBaseType="Orchard.Mvc.ViewEngines.Razor.WebViewPage">
|
||||
<namespaces>
|
||||
<add namespace="System.Web.Mvc" />
|
||||
<add namespace="System.Web.Mvc.Ajax" />
|
||||
<add namespace="System.Web.Mvc.Html" />
|
||||
<add namespace="System.Web.Routing" />
|
||||
<add namespace="System.Web.WebPages" />
|
||||
<add namespace="System.Linq" />
|
||||
<add namespace="System.Collections.Generic" />
|
||||
<add namespace="Orchard.Mvc.Html" />
|
||||
</namespaces>
|
||||
</pages>
|
||||
</system.web.webPages.razor>
|
||||
<!--
|
||||
For a description of web.config changes see http://go.microsoft.com/fwlink/?LinkId=235367.
|
||||
|
||||
The following attributes can be set on the <httpRuntime> tag.
|
||||
<system.Web>
|
||||
<httpRuntime targetFramework="4.5.2" />
|
||||
</system.Web>
|
||||
-->
|
||||
<system.web>
|
||||
<compilation targetFramework="4.5.2" debug="true">
|
||||
<assemblies>
|
||||
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
|
||||
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
|
||||
<add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
|
||||
<add assembly="System.Web.Mvc, Version=5.2.3, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
|
||||
<add assembly="System.Web.WebPages, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
|
||||
</assemblies>
|
||||
</compilation>
|
||||
</system.web>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Autofac" publicKeyToken="17863af14b0044da" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-3.5.0.0" newVersion="3.5.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.0.4000" newVersion="4.0.0.4000" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Iesi.Collections" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.IdentityModel.Tokens.Jwt" publicKeyToken="31bf3856ad364e35" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.0.0.127" newVersion="5.0.0.127" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Microsoft.IdentityModel.Protocol.Extensions" publicKeyToken="31bf3856ad364e35" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-1.0.2.33" newVersion="1.0.2.33" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
|
||||
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
|
||||
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
|
||||
<bindingRedirect oldVersion="1.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
||||
@@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Iesi.Collections" version="4.0.1.4000" targetFramework="net452" />
|
||||
<package id="Microsoft.AspNet.Mvc" version="5.2.3" targetFramework="net451" />
|
||||
<package id="Microsoft.AspNet.Razor" version="3.2.3" targetFramework="net451" />
|
||||
<package id="Microsoft.AspNet.WebPages" version="3.2.3" targetFramework="net451" />
|
||||
<package id="Microsoft.Azure.ActiveDirectory.GraphClient" version="2.1.0" targetFramework="net452" />
|
||||
<package id="Microsoft.Data.Edm" version="5.6.4" targetFramework="net452" />
|
||||
<package id="Microsoft.Data.OData" version="5.6.4" targetFramework="net452" />
|
||||
<package id="Microsoft.Data.Services.Client" version="5.6.4" targetFramework="net452" />
|
||||
<package id="Microsoft.IdentityModel.Clients.ActiveDirectory" version="2.19.208020213" targetFramework="net452" />
|
||||
<package id="Microsoft.IdentityModel.Logging" version="1.0.0" targetFramework="net451" />
|
||||
<package id="Microsoft.IdentityModel.Protocol.Extensions" version="1.0.2.206221351" targetFramework="net451" />
|
||||
<package id="Microsoft.IdentityModel.Tokens" version="5.0.0" targetFramework="net451" />
|
||||
<package id="Microsoft.Owin" version="3.0.1" targetFramework="net451" />
|
||||
<package id="Microsoft.Owin.Host.SystemWeb" version="3.0.1" targetFramework="net451" />
|
||||
<package id="Microsoft.Owin.Security" version="3.0.1" targetFramework="net451" />
|
||||
<package id="Microsoft.Owin.Security.ActiveDirectory" version="3.0.1" targetFramework="net451" />
|
||||
<package id="Microsoft.Owin.Security.Cookies" version="3.0.1" targetFramework="net451" />
|
||||
<package id="Microsoft.Owin.Security.Jwt" version="3.0.1" targetFramework="net451" />
|
||||
<package id="Microsoft.Owin.Security.OAuth" version="3.0.1" targetFramework="net451" />
|
||||
<package id="Microsoft.Owin.Security.OpenIdConnect" version="3.0.1" targetFramework="net451" />
|
||||
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net451" />
|
||||
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net451" />
|
||||
<package id="NHibernate" version="4.0.1.4000" targetFramework="net452" />
|
||||
<package id="Owin" version="1.0" targetFramework="net451" />
|
||||
<package id="System.IdentityModel.Tokens.Jwt" version="5.0.0" targetFramework="net451" />
|
||||
<package id="System.Spatial" version="5.6.4" targetFramework="net452" />
|
||||
</packages>
|
||||
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<Placement>
|
||||
<Place Parts_AzureSettings_Edit="Content:1"/>
|
||||
</Placement>
|
||||
@@ -147,7 +147,7 @@ namespace Orchard.Azure.MediaServices.Controllers {
|
||||
_transactionManager.Cancel();
|
||||
|
||||
Logger.Error(ex, "Error while deleting asset with ID {0}.", id);
|
||||
_notifier.Error(T("Ar error occurred while deleting the asset '{0}':\n{1}", asset.Name, ex.Message));
|
||||
_notifier.Error(T("An error occurred while deleting the asset '{0}':\n{1}", asset.Name, ex.Message));
|
||||
}
|
||||
|
||||
return Redirect(Url.ItemEditUrl(cloudVideoPart));
|
||||
@@ -182,4 +182,4 @@ namespace Orchard.Azure.MediaServices.Controllers {
|
||||
ModelState.AddModelError(key, errorMessage.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,7 +164,7 @@ namespace Orchard.Azure.MediaServices.Controllers {
|
||||
_transactionManager.Cancel();
|
||||
|
||||
Logger.Error(ex, "Error while creating job with task of type {0} on cloud video item with ID {1}.", task, id);
|
||||
_notifier.Error(T("Ar error occurred while creating the job:\n{0}", ex.Message));
|
||||
_notifier.Error(T("An error occurred while creating the job:\n{0}", ex.Message));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -253,4 +253,4 @@ namespace Orchard.Azure.MediaServices.Controllers {
|
||||
ModelState.AddModelError(key, errorMessage.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,8 +29,8 @@ namespace Orchard.Azure.MediaServices.Controllers {
|
||||
private readonly IAuthorizer _authorizer;
|
||||
|
||||
public MediaController(
|
||||
IOrchardServices services,
|
||||
IAssetManager assetManager,
|
||||
IOrchardServices services,
|
||||
IAssetManager assetManager,
|
||||
ITransactionManager transactionManager) {
|
||||
|
||||
_contentManager = services.ContentManager;
|
||||
@@ -124,7 +124,7 @@ namespace Orchard.Azure.MediaServices.Controllers {
|
||||
Logger.Debug("User requested to save cloud video item with ID {0}.", part.Id);
|
||||
|
||||
var editorShape = _contentManager.UpdateEditor(part, this);
|
||||
|
||||
|
||||
if (!ModelState.IsValid) {
|
||||
_transactionManager.Cancel();
|
||||
|
||||
@@ -153,8 +153,8 @@ namespace Orchard.Azure.MediaServices.Controllers {
|
||||
catch (Exception ex) {
|
||||
_transactionManager.Cancel();
|
||||
|
||||
Logger.Error(ex, "Error while saving cloud video item with ID {0}.", part.Id);
|
||||
_notifier.Error(T("Ar error occurred while saving the cloud video item:\n{1}", ex.Message));
|
||||
Logger.Error(ex, "Error while saving cloud video item with ID {0}.", part.Id);
|
||||
_notifier.Error(T("An error occurred while saving the cloud video item:\n{1}", ex.Message));
|
||||
}
|
||||
|
||||
return RedirectToAction("Edit", new { id = part.Id });
|
||||
@@ -168,4 +168,4 @@ namespace Orchard.Azure.MediaServices.Controllers {
|
||||
ModelState.AddModelError(key, errorMessage.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,5 +20,5 @@
|
||||
<fieldset>
|
||||
@Html.CheckBoxFor(m => m.ShowFullMenu)
|
||||
@Html.LabelFor(m => m.ShowFullMenu, T("No filter on selected page").Text, new { @class = "forcheckbox" })
|
||||
@Html.Hint(T("Check for the menu to be display without filtering the selected current page."))
|
||||
</fieldset>
|
||||
@Html.Hint(T("Check for the menu to be displayed without filtering the selected current page."))
|
||||
</fieldset>
|
||||
|
||||
@@ -89,7 +89,7 @@ namespace Orchard.Projections.Providers.Layouts {
|
||||
_EmptyCell: Shape.TextBox(
|
||||
Id: "empty-cell", Name: "EmptyCell",
|
||||
Title: T("Empty Cell"),
|
||||
Description: T("The HTML to render as empty cells to fill a row. (e.g., <td> </td>"),
|
||||
Description: T("The HTML to render as empty cells to fill a row. (e.g., <td> </td>)"),
|
||||
Classes: new[] { "text medium", "tokenized" }
|
||||
)
|
||||
)
|
||||
@@ -125,4 +125,4 @@ namespace Orchard.Projections.Providers.Layouts {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace Orchard.Scripting.CSharp.Forms {
|
||||
}
|
||||
|
||||
public void Validating(ValidatingContext context) {
|
||||
if (context.FormName == "ActionDecision") {
|
||||
if (context.FormName == "ActivityActionDecision") {
|
||||
if (context.ValueProvider.GetValue("Script").AttemptedValue == string.Empty) {
|
||||
context.ModelState.AddModelError("Script", T("You must provide a Script").Text);
|
||||
}
|
||||
@@ -57,4 +57,4 @@ namespace Orchard.Scripting.CSharp.Forms {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using Orchard.Commands;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Security;
|
||||
using Orchard.Users.Services;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Orchard.Users.Commands {
|
||||
public class UserCommands : DefaultOrchardCommandHandler {
|
||||
@@ -40,8 +42,11 @@ namespace Orchard.Users.Commands {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Password == null || Password.Length < MinPasswordLength) {
|
||||
Context.Output.WriteLine(T("You must specify a password of {0} or more characters.", MinPasswordLength));
|
||||
IDictionary<string, LocalizedString> validationErrors;
|
||||
if (!_userService.PasswordMeetsPolicies(Password, out validationErrors)) {
|
||||
foreach (var error in validationErrors) {
|
||||
Context.Output.WriteLine(error.Value);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -53,11 +58,5 @@ namespace Orchard.Users.Commands {
|
||||
|
||||
Context.Output.WriteLine(T("User created successfully"));
|
||||
}
|
||||
|
||||
int MinPasswordLength {
|
||||
get {
|
||||
return _membershipService.GetSettings().MinRequiredPasswordLength;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace Orchard.Users.Constants {
|
||||
public static class UserPasswordValidationResults {
|
||||
public const string PasswordIsTooShort = "PasswordIsTooShort";
|
||||
public const string PasswordDoesNotContainNumbers = "PasswordDoesNotContainNumbers";
|
||||
public const string PasswordDoesNotContainUppercase = "PasswordDoesNotContainUppercase";
|
||||
public const string PasswordDoesNotContainLowercase = "PasswordDoesNotContainLowercase";
|
||||
public const string PasswordDoesNotContainSpecialCharacters = "PasswordDoesNotContainSpecialCharacters";
|
||||
}
|
||||
}
|
||||
@@ -1,20 +1,22 @@
|
||||
using System;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Localization;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Security;
|
||||
using Orchard.Logging;
|
||||
using Orchard.Mvc;
|
||||
using Orchard.Mvc.Extensions;
|
||||
using Orchard.Security;
|
||||
using Orchard.Themes;
|
||||
using Orchard.Users.Services;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Users.Models;
|
||||
using Orchard.UI.Notify;
|
||||
using Orchard.Users.Events;
|
||||
using Orchard.Users.Models;
|
||||
using Orchard.Users.Services;
|
||||
using Orchard.Utility.Extensions;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Security;
|
||||
using Orchard.Services;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Orchard.Users.Controllers {
|
||||
[HandleError, Themed]
|
||||
@@ -24,18 +26,23 @@ namespace Orchard.Users.Controllers {
|
||||
private readonly IUserService _userService;
|
||||
private readonly IOrchardServices _orchardServices;
|
||||
private readonly IUserEventHandler _userEventHandler;
|
||||
private readonly IClock _clock;
|
||||
|
||||
public AccountController(
|
||||
IAuthenticationService authenticationService,
|
||||
IAuthenticationService authenticationService,
|
||||
IMembershipService membershipService,
|
||||
IUserService userService,
|
||||
IUserService userService,
|
||||
IOrchardServices orchardServices,
|
||||
IUserEventHandler userEventHandler) {
|
||||
IUserEventHandler userEventHandler,
|
||||
IClock clock) {
|
||||
|
||||
_authenticationService = authenticationService;
|
||||
_membershipService = membershipService;
|
||||
_userService = userService;
|
||||
_orchardServices = orchardServices;
|
||||
_userEventHandler = userEventHandler;
|
||||
_clock = clock;
|
||||
|
||||
Logger = NullLogger.Instance;
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
@@ -51,7 +58,7 @@ namespace Orchard.Users.Controllers {
|
||||
if (currentUser == null) {
|
||||
Logger.Information("Access denied to anonymous request on {0}", returnUrl);
|
||||
var shape = _orchardServices.New.LogOn().Title(T("Access Denied").Text);
|
||||
return new ShapeResult(this, shape);
|
||||
return new ShapeResult(this, shape);
|
||||
}
|
||||
|
||||
//TODO: (erikpo) Add a setting for whether or not to log access denieds since these can fill up a database pretty fast from bots on a high traffic site
|
||||
@@ -69,7 +76,7 @@ namespace Orchard.Users.Controllers {
|
||||
return this.RedirectLocal(returnUrl);
|
||||
|
||||
var shape = _orchardServices.New.LogOn().Title(T("Log On").Text);
|
||||
return new ShapeResult(this, shape);
|
||||
return new ShapeResult(this, shape);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
@@ -83,7 +90,16 @@ namespace Orchard.Users.Controllers {
|
||||
var user = ValidateLogOn(userNameOrEmail, password);
|
||||
if (!ModelState.IsValid) {
|
||||
var shape = _orchardServices.New.LogOn().Title(T("Log On").Text);
|
||||
return new ShapeResult(this, shape);
|
||||
|
||||
return new ShapeResult(this, shape);
|
||||
}
|
||||
|
||||
var membershipSettings = _membershipService.GetSettings();
|
||||
if (user != null &&
|
||||
membershipSettings.EnableCustomPasswordPolicy &&
|
||||
membershipSettings.EnablePasswordExpiration &&
|
||||
_membershipService.PasswordIsExpired(user, membershipSettings.PasswordExpirationTimeInDays)) {
|
||||
return RedirectToAction("ChangeExpiredPassword", new { username = user.UserName });
|
||||
}
|
||||
|
||||
_authenticationService.SignIn(user, rememberMe);
|
||||
@@ -103,24 +119,19 @@ namespace Orchard.Users.Controllers {
|
||||
return this.RedirectLocal(returnUrl);
|
||||
}
|
||||
|
||||
int MinPasswordLength {
|
||||
get {
|
||||
return _membershipService.GetSettings().MinRequiredPasswordLength;
|
||||
}
|
||||
}
|
||||
|
||||
[AlwaysAccessible]
|
||||
public ActionResult Register() {
|
||||
// ensure users can register
|
||||
var registrationSettings = _orchardServices.WorkContext.CurrentSite.As<RegistrationSettingsPart>();
|
||||
if ( !registrationSettings.UsersCanRegister ) {
|
||||
var membershipSettings = _membershipService.GetSettings();
|
||||
if (!membershipSettings.UsersCanRegister) {
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
ViewData["PasswordLength"] = MinPasswordLength;
|
||||
ViewData["PasswordLength"] = membershipSettings.GetMinimumPasswordLength();
|
||||
|
||||
var shape = _orchardServices.New.Register();
|
||||
return new ShapeResult(this, shape);
|
||||
|
||||
return new ShapeResult(this, shape);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
@@ -128,12 +139,12 @@ namespace Orchard.Users.Controllers {
|
||||
[ValidateInput(false)]
|
||||
public ActionResult Register(string userName, string email, string password, string confirmPassword, string returnUrl = null) {
|
||||
// ensure users can register
|
||||
var registrationSettings = _orchardServices.WorkContext.CurrentSite.As<RegistrationSettingsPart>();
|
||||
if ( !registrationSettings.UsersCanRegister ) {
|
||||
var membershipSettings = _membershipService.GetSettings();
|
||||
if (!membershipSettings.UsersCanRegister) {
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
ViewData["PasswordLength"] = MinPasswordLength;
|
||||
ViewData["PasswordLength"] = membershipSettings.GetMinimumPasswordLength();
|
||||
|
||||
if (ValidateRegistration(userName, email, password, confirmPassword)) {
|
||||
// Attempt to register the user
|
||||
@@ -141,13 +152,13 @@ namespace Orchard.Users.Controllers {
|
||||
var user = _membershipService.CreateUser(new CreateUserParams(userName, password, email, null, null, false));
|
||||
|
||||
if (user != null) {
|
||||
if ( user.As<UserPart>().EmailStatus == UserStatus.Pending ) {
|
||||
if (user.As<UserPart>().EmailStatus == UserStatus.Pending) {
|
||||
var siteUrl = _orchardServices.WorkContext.CurrentSite.BaseUrl;
|
||||
if(String.IsNullOrWhiteSpace(siteUrl)) {
|
||||
if (String.IsNullOrWhiteSpace(siteUrl)) {
|
||||
siteUrl = HttpContext.Request.ToRootUrlString();
|
||||
}
|
||||
|
||||
_userService.SendChallengeEmail(user.As<UserPart>(), nonce => Url.MakeAbsolute(Url.Action("ChallengeEmail", "Account", new {Area = "Orchard.Users", nonce = nonce}), siteUrl));
|
||||
_userService.SendChallengeEmail(user.As<UserPart>(), nonce => Url.MakeAbsolute(Url.Action("ChallengeEmail", "Account", new { Area = "Orchard.Users", nonce = nonce }), siteUrl));
|
||||
|
||||
_userEventHandler.SentChallengeEmail(user);
|
||||
return RedirectToAction("ChallengeEmailSent", new { ReturnUrl = returnUrl });
|
||||
@@ -163,20 +174,20 @@ namespace Orchard.Users.Controllers {
|
||||
|
||||
return this.RedirectLocal(returnUrl);
|
||||
}
|
||||
|
||||
|
||||
ModelState.AddModelError("_FORM", T(ErrorCodeToString(/*createStatus*/MembershipCreateStatus.ProviderError)));
|
||||
}
|
||||
|
||||
// If we got this far, something failed, redisplay form
|
||||
var shape = _orchardServices.New.Register();
|
||||
return new ShapeResult(this, shape);
|
||||
return new ShapeResult(this, shape);
|
||||
}
|
||||
|
||||
[AlwaysAccessible]
|
||||
public ActionResult RequestLostPassword() {
|
||||
// ensure users can request lost password
|
||||
var registrationSettings = _orchardServices.WorkContext.CurrentSite.As<RegistrationSettingsPart>();
|
||||
if ( !registrationSettings.EnableLostPassword ) {
|
||||
var membershipSettings = _membershipService.GetSettings();
|
||||
if (!membershipSettings.EnableLostPassword) {
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
@@ -187,12 +198,12 @@ namespace Orchard.Users.Controllers {
|
||||
[AlwaysAccessible]
|
||||
public ActionResult RequestLostPassword(string username) {
|
||||
// ensure users can request lost password
|
||||
var registrationSettings = _orchardServices.WorkContext.CurrentSite.As<RegistrationSettingsPart>();
|
||||
if ( !registrationSettings.EnableLostPassword ) {
|
||||
var membershipSettings = _membershipService.GetSettings();
|
||||
if (!membershipSettings.EnableLostPassword) {
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
if(String.IsNullOrWhiteSpace(username)){
|
||||
if (String.IsNullOrWhiteSpace(username)) {
|
||||
ModelState.AddModelError("username", T("You must specify a username or e-mail."));
|
||||
return View();
|
||||
}
|
||||
@@ -205,14 +216,15 @@ namespace Orchard.Users.Controllers {
|
||||
_userService.SendLostPasswordEmail(username, nonce => Url.MakeAbsolute(Url.Action("LostPassword", "Account", new { Area = "Orchard.Users", nonce = nonce }), siteUrl));
|
||||
|
||||
_orchardServices.Notifier.Information(T("Check your e-mail for the confirmation link."));
|
||||
|
||||
|
||||
return RedirectToAction("LogOn");
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[AlwaysAccessible]
|
||||
public ActionResult ChangePassword() {
|
||||
ViewData["PasswordLength"] = MinPasswordLength;
|
||||
var membershipSettings = _membershipService.GetSettings();
|
||||
ViewData["PasswordLength"] = membershipSettings.GetMinimumPasswordLength();
|
||||
|
||||
return View();
|
||||
}
|
||||
@@ -224,27 +236,76 @@ namespace Orchard.Users.Controllers {
|
||||
[SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes",
|
||||
Justification = "Exceptions result in password not being changed.")]
|
||||
public ActionResult ChangePassword(string currentPassword, string newPassword, string confirmPassword) {
|
||||
ViewData["PasswordLength"] = MinPasswordLength;
|
||||
var membershipSettings = _membershipService.GetSettings();
|
||||
ViewData["PasswordLength"] = membershipSettings.GetMinimumPasswordLength(); ;
|
||||
|
||||
if ( !ValidateChangePassword(currentPassword, newPassword, confirmPassword) ) {
|
||||
if (!ValidateChangePassword(currentPassword, newPassword, confirmPassword)) {
|
||||
return View();
|
||||
}
|
||||
|
||||
try {
|
||||
var validated = _membershipService.ValidateUser(User.Identity.Name, currentPassword);
|
||||
if (PasswordChangeIsSuccess(currentPassword, newPassword, _orchardServices.WorkContext.CurrentUser.UserName)) {
|
||||
return RedirectToAction("ChangePasswordSuccess");
|
||||
}
|
||||
else {
|
||||
return ChangePassword();
|
||||
}
|
||||
}
|
||||
|
||||
if ( validated != null ) {
|
||||
[AlwaysAccessible]
|
||||
public ActionResult ChangeExpiredPassword(string username) {
|
||||
var membershipSettings = _membershipService.GetSettings();
|
||||
var lastPasswordChangeUtc = _membershipService.GetUser(username).As<UserPart>().LastPasswordChangeUtc;
|
||||
|
||||
if (lastPasswordChangeUtc.Value.AddDays(membershipSettings.PasswordExpirationTimeInDays) >
|
||||
_clock.UtcNow) {
|
||||
return RedirectToAction("LogOn");
|
||||
}
|
||||
|
||||
var viewModel = _orchardServices.New.ViewModel(
|
||||
Username: username,
|
||||
PasswordLength: membershipSettings.GetMinimumPasswordLength());
|
||||
|
||||
return View(viewModel);
|
||||
}
|
||||
|
||||
[HttpPost, AlwaysAccessible, ValidateInput(false)]
|
||||
public ActionResult ChangeExpiredPassword(string currentPassword, string newPassword, string confirmPassword, string username) {
|
||||
var membershipSettings = _membershipService.GetSettings();
|
||||
var viewModel = _orchardServices.New.ViewModel(
|
||||
Username: username,
|
||||
PasswordLength: membershipSettings.GetMinimumPasswordLength());
|
||||
|
||||
if (!ValidateChangePassword(currentPassword, newPassword, confirmPassword)) {
|
||||
return View(viewModel);
|
||||
}
|
||||
|
||||
if (PasswordChangeIsSuccess(currentPassword, newPassword, username)) {
|
||||
return RedirectToAction("ChangePasswordSuccess");
|
||||
}
|
||||
else {
|
||||
return View(viewModel);
|
||||
}
|
||||
}
|
||||
|
||||
private bool PasswordChangeIsSuccess(string currentPassword, string newPassword, string username) {
|
||||
try {
|
||||
var validated = _membershipService.ValidateUser(username, currentPassword);
|
||||
|
||||
if (validated != null) {
|
||||
_membershipService.SetPassword(validated, newPassword);
|
||||
_userEventHandler.ChangedPassword(validated);
|
||||
return RedirectToAction("ChangePasswordSuccess");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
ModelState.AddModelError("_FORM",
|
||||
T("The current password is incorrect or the new password is invalid."));
|
||||
return ChangePassword();
|
||||
} catch {
|
||||
|
||||
ModelState.AddModelError("_FORM", T("The current password is incorrect or the new password is invalid."));
|
||||
return ChangePassword();
|
||||
|
||||
return false;
|
||||
}
|
||||
catch {
|
||||
ModelState.AddModelError("_FORM", T("The current password is incorrect or the new password is invalid."));
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -254,7 +315,8 @@ namespace Orchard.Users.Controllers {
|
||||
return RedirectToAction("LogOn");
|
||||
}
|
||||
|
||||
ViewData["PasswordLength"] = MinPasswordLength;
|
||||
var membershipSettings = _membershipService.GetSettings();
|
||||
ViewData["PasswordLength"] = membershipSettings.GetMinimumPasswordLength();
|
||||
|
||||
return View();
|
||||
}
|
||||
@@ -268,11 +330,10 @@ namespace Orchard.Users.Controllers {
|
||||
return Redirect("~/");
|
||||
}
|
||||
|
||||
ViewData["PasswordLength"] = MinPasswordLength;
|
||||
var membershipSettings = _membershipService.GetSettings();
|
||||
ViewData["PasswordLength"] = membershipSettings.GetMinimumPasswordLength();
|
||||
|
||||
if (newPassword == null || newPassword.Length < MinPasswordLength) {
|
||||
ModelState.AddModelError("newPassword", T("You must specify a new password of {0} or more characters.", MinPasswordLength));
|
||||
}
|
||||
ValidatePassword(newPassword);
|
||||
|
||||
if (!String.Equals(newPassword, confirmPassword, StringComparison.Ordinal)) {
|
||||
ModelState.AddModelError("_FORM", T("The new password and confirmation password do not match."));
|
||||
@@ -327,10 +388,13 @@ namespace Orchard.Users.Controllers {
|
||||
if ( String.IsNullOrEmpty(currentPassword) ) {
|
||||
ModelState.AddModelError("currentPassword", T("You must specify a current password."));
|
||||
}
|
||||
if ( newPassword == null || newPassword.Length < MinPasswordLength ) {
|
||||
ModelState.AddModelError("newPassword", T("You must specify a new password of {0} or more characters.", MinPasswordLength));
|
||||
|
||||
if (String.Equals(currentPassword, newPassword, StringComparison.Ordinal)) {
|
||||
ModelState.AddModelError("newPassword", T("The new password must be different from the current password."));
|
||||
}
|
||||
|
||||
ValidatePassword(newPassword);
|
||||
|
||||
if ( !String.Equals(newPassword, confirmPassword, StringComparison.Ordinal) ) {
|
||||
ModelState.AddModelError("_FORM", T("The new password and confirmation password do not match."));
|
||||
}
|
||||
@@ -397,15 +461,25 @@ namespace Orchard.Users.Controllers {
|
||||
if (!_userService.VerifyUserUnicity(userName, email)) {
|
||||
ModelState.AddModelError("userExists", T("User with that username and/or email already exists."));
|
||||
}
|
||||
if (password == null || password.Length < MinPasswordLength) {
|
||||
ModelState.AddModelError("password", T("You must specify a password of {0} or more characters.", MinPasswordLength));
|
||||
}
|
||||
|
||||
ValidatePassword(password);
|
||||
|
||||
if (!String.Equals(password, confirmPassword, StringComparison.Ordinal)) {
|
||||
ModelState.AddModelError("_FORM", T("The new password and confirmation password do not match."));
|
||||
}
|
||||
return ModelState.IsValid;
|
||||
}
|
||||
|
||||
private void ValidatePassword(string password) {
|
||||
IDictionary<string, LocalizedString> validationErrors;
|
||||
|
||||
if (!_userService.PasswordMeetsPolicies(password, out validationErrors)) {
|
||||
foreach (var error in validationErrors) {
|
||||
ModelState.AddModelError(error.Key, error.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static string ErrorCodeToString(MembershipCreateStatus createStatus) {
|
||||
// See http://msdn.microsoft.com/en-us/library/system.web.security.membershipcreatestatus.aspx for
|
||||
// a full list of status codes.
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
@@ -8,16 +9,15 @@ using Orchard.Core.Settings.Models;
|
||||
using Orchard.DisplayManagement;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Mvc;
|
||||
using Orchard.Mvc.Extensions;
|
||||
using Orchard.Security;
|
||||
using Orchard.Settings;
|
||||
using Orchard.UI.Navigation;
|
||||
using Orchard.UI.Notify;
|
||||
using Orchard.Users.Events;
|
||||
using Orchard.Users.Models;
|
||||
using Orchard.Users.Services;
|
||||
using Orchard.Users.ViewModels;
|
||||
using Orchard.Mvc.Extensions;
|
||||
using System;
|
||||
using Orchard.Settings;
|
||||
using Orchard.UI.Navigation;
|
||||
using Orchard.Utility.Extensions;
|
||||
|
||||
namespace Orchard.Users.Controllers {
|
||||
@@ -35,6 +35,7 @@ namespace Orchard.Users.Controllers {
|
||||
IShapeFactory shapeFactory,
|
||||
IUserEventHandler userEventHandlers,
|
||||
ISiteService siteService) {
|
||||
|
||||
Services = services;
|
||||
_membershipService = membershipService;
|
||||
_userService = userService;
|
||||
@@ -189,6 +190,12 @@ namespace Orchard.Users.Controllers {
|
||||
AddModelError("ConfirmPassword", T("Password confirmation must match"));
|
||||
}
|
||||
|
||||
IDictionary<string, LocalizedString> validationErrors;
|
||||
|
||||
if (!_userService.PasswordMeetsPolicies(createModel.Password, out validationErrors)) {
|
||||
ModelState.AddModelErrors(validationErrors);
|
||||
}
|
||||
|
||||
var user = Services.ContentManager.New<IUser>("User");
|
||||
if (ModelState.IsValid) {
|
||||
user = _membershipService.CreateUser(new CreateUserParams(
|
||||
|
||||
@@ -4,18 +4,26 @@ using Orchard.Environment.Extensions;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Security;
|
||||
using Orchard.Users.Models;
|
||||
using Orchard.Users.Services;
|
||||
using Orchard.Users.ViewModels;
|
||||
using System.Collections.Generic;
|
||||
using System.Web.Mvc;
|
||||
|
||||
namespace Orchard.Users.Drivers{
|
||||
|
||||
[OrchardFeature("Orchard.Users.PasswordEditor")]
|
||||
public class UserPartPasswordDriver : ContentPartDriver<UserPart> {
|
||||
private readonly IMembershipService _membershipService;
|
||||
|
||||
private readonly IUserService _userService;
|
||||
|
||||
public Localizer T { get; set; }
|
||||
|
||||
public UserPartPasswordDriver(IMembershipService membershipService) {
|
||||
public UserPartPasswordDriver(
|
||||
MembershipService membershipService,
|
||||
IUserService userService) {
|
||||
|
||||
_membershipService = membershipService;
|
||||
_userService = userService;
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
|
||||
@@ -43,6 +51,11 @@ namespace Orchard.Users.Drivers{
|
||||
_membershipService.SetPassword(actUser, editModel.Password);
|
||||
}
|
||||
}
|
||||
|
||||
IDictionary<string, LocalizedString> validationErrors;
|
||||
if (!_userService.PasswordMeetsPolicies(editModel.Password, out validationErrors)) {
|
||||
updater.AddModelErrors(validationErrors);
|
||||
}
|
||||
}
|
||||
}
|
||||
return Editor(part, shapeHelper);
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace Orchard.Security {
|
||||
public static class MembershipSettingsExtensions {
|
||||
public static int GetMinimumPasswordLength(this IMembershipSettings membershipSettings) {
|
||||
return membershipSettings.EnableCustomPasswordPolicy ? membershipSettings.MinimumPasswordLength : 7;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using Orchard.Localization;
|
||||
using System.Collections.Generic;
|
||||
using Orchard.Mvc.Extensions;
|
||||
|
||||
namespace System.Web.Mvc {
|
||||
public static class ModelStateDictionaryExtensions {
|
||||
public static void AddModelErrors(this ModelStateDictionary modelStateDictionary, IDictionary<string, LocalizedString> validationErrors) {
|
||||
foreach (var error in validationErrors) {
|
||||
modelStateDictionary.AddModelError(error.Key, error.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using Orchard.Localization;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Orchard.ContentManagement {
|
||||
public static class UpdateModelExtensions {
|
||||
public static void AddModelErrors(this IUpdateModel updateModel, IDictionary<string, LocalizedString> validationErrors) {
|
||||
foreach (var error in validationErrors) {
|
||||
updateModel.AddModelError(error.Key, error.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using Orchard.ContentManagement.MetaData;
|
||||
using Orchard.ContentManagement.MetaData;
|
||||
using Orchard.Core.Contents.Extensions;
|
||||
using Orchard.Data.Migration;
|
||||
using System;
|
||||
|
||||
namespace Orchard.Users {
|
||||
public class UsersDataMigration : DataMigrationImpl {
|
||||
@@ -23,11 +23,12 @@ namespace Orchard.Users {
|
||||
.Column<DateTime>("CreatedUtc")
|
||||
.Column<DateTime>("LastLoginUtc")
|
||||
.Column<DateTime>("LastLogoutUtc")
|
||||
.Column<DateTime>("LastPasswordChangeUtc")
|
||||
);
|
||||
|
||||
ContentDefinitionManager.AlterTypeDefinition("User", cfg => cfg.Creatable(false));
|
||||
|
||||
return 4;
|
||||
return 5;
|
||||
}
|
||||
|
||||
public int UpdateFrom1() {
|
||||
@@ -54,5 +55,14 @@ namespace Orchard.Users {
|
||||
|
||||
return 4;
|
||||
}
|
||||
|
||||
public int UpdateFrom4() {
|
||||
SchemaBuilder.AlterTable("UserPartRecord",
|
||||
table => {
|
||||
table.AddColumn<DateTime>("LastPasswordChangeUtc");
|
||||
});
|
||||
|
||||
return 5;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,10 @@
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Security;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Web.Security;
|
||||
|
||||
namespace Orchard.Users.Models {
|
||||
public class RegistrationSettingsPart : ContentPart {
|
||||
public class RegistrationSettingsPart : ContentPart, IMembershipSettings {
|
||||
public bool UsersCanRegister {
|
||||
get { return this.Retrieve(x => x.UsersCanRegister); }
|
||||
set { this.Store(x => x.UsersCanRegister, value); }
|
||||
@@ -42,5 +45,51 @@ namespace Orchard.Users.Models {
|
||||
set { this.Store(x => x.EnableLostPassword, value); }
|
||||
}
|
||||
|
||||
public bool EnableCustomPasswordPolicy {
|
||||
get { return this.Retrieve(x => x.EnableCustomPasswordPolicy); }
|
||||
set { this.Store(x => x.EnableCustomPasswordPolicy, value); }
|
||||
}
|
||||
|
||||
[Range(1, int.MaxValue, ErrorMessage = "The minimum password length must be at least 1.")]
|
||||
public int MinimumPasswordLength {
|
||||
get { return this.Retrieve(x => x.MinimumPasswordLength, 7); }
|
||||
set { this.Store(x => x.MinimumPasswordLength, value); }
|
||||
}
|
||||
|
||||
public bool EnablePasswordUppercaseRequirement {
|
||||
get { return this.Retrieve(x => x.EnablePasswordUppercaseRequirement); }
|
||||
set { this.Store(x => x.EnablePasswordUppercaseRequirement, value); }
|
||||
}
|
||||
|
||||
public bool EnablePasswordLowercaseRequirement {
|
||||
get { return this.Retrieve(x => x.EnablePasswordLowercaseRequirement); }
|
||||
set { this.Store(x => x.EnablePasswordLowercaseRequirement, value); }
|
||||
}
|
||||
|
||||
public bool EnablePasswordNumberRequirement {
|
||||
get { return this.Retrieve(x => x.EnablePasswordNumberRequirement); }
|
||||
set { this.Store(x => x.EnablePasswordNumberRequirement, value); }
|
||||
}
|
||||
|
||||
public bool EnablePasswordSpecialRequirement {
|
||||
get { return this.Retrieve(x => x.EnablePasswordSpecialRequirement); }
|
||||
set { this.Store(x => x.EnablePasswordSpecialRequirement, value); }
|
||||
}
|
||||
|
||||
public bool EnablePasswordExpiration {
|
||||
get { return this.Retrieve(x => x.EnablePasswordExpiration); }
|
||||
set { this.Store(x => x.EnablePasswordExpiration, value); }
|
||||
}
|
||||
|
||||
[Range(1, int.MaxValue, ErrorMessage = "The password expiration time must be a minimum of 1 day.")]
|
||||
public int PasswordExpirationTimeInDays {
|
||||
get { return this.Retrieve(x => x.PasswordExpirationTimeInDays, 30); }
|
||||
set { this.Store(x => x.PasswordExpirationTimeInDays, value); }
|
||||
}
|
||||
|
||||
public MembershipPasswordFormat PasswordFormat {
|
||||
get { return this.Retrieve(x => x.PasswordFormat, MembershipPasswordFormat.Hashed); }
|
||||
set { this.Store(x => x.PasswordFormat, value); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Web.Security;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Security;
|
||||
using System;
|
||||
using System.Web.Security;
|
||||
|
||||
namespace Orchard.Users.Models {
|
||||
public sealed class UserPart : ContentPart<UserPartRecord>, IUser {
|
||||
@@ -76,5 +76,10 @@ namespace Orchard.Users.Models {
|
||||
get { return Retrieve(x => x.LastLogoutUtc); }
|
||||
set { Store(x => x.LastLogoutUtc, value); }
|
||||
}
|
||||
|
||||
public DateTime? LastPasswordChangeUtc {
|
||||
get { return Retrieve(x => x.LastPasswordChangeUtc); }
|
||||
set { Store(x => x.LastPasswordChangeUtc, value); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using Orchard.ContentManagement.Records;
|
||||
using System;
|
||||
using System.Web.Security;
|
||||
using Orchard.ContentManagement.Records;
|
||||
|
||||
namespace Orchard.Users.Models {
|
||||
public class UserPartRecord : ContentPartRecord {
|
||||
@@ -19,5 +19,6 @@ namespace Orchard.Users.Models {
|
||||
public virtual DateTime? CreatedUtc { get; set; }
|
||||
public virtual DateTime? LastLoginUtc { get; set; }
|
||||
public virtual DateTime? LastLogoutUtc { get; set; }
|
||||
public virtual DateTime? LastPasswordChangeUtc { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -99,15 +99,19 @@
|
||||
<Compile Include="Activities\UserActivity.cs" />
|
||||
<Compile Include="Activities\UserIsApprovedActivity.cs" />
|
||||
<Compile Include="Commands\UserCommands.cs" />
|
||||
<Compile Include="Constants\UserPasswordValidationResults.cs" />
|
||||
<Compile Include="Controllers\AccountController.cs" />
|
||||
<Compile Include="Controllers\AdminController.cs" />
|
||||
<Compile Include="Drivers\UserPartDriver.cs" />
|
||||
<Compile Include="Drivers\UserPartPasswordDriver.cs" />
|
||||
<Compile Include="Events\LoginUserEventHandler.cs" />
|
||||
<Compile Include="Extensions\MembershipSettingsExtensions.cs" />
|
||||
<Compile Include="Extensions\UpdateModelExtensions.cs" />
|
||||
<Compile Include="Forms\SignInUserForm.cs" />
|
||||
<Compile Include="Forms\VerifyUserUnicityForm.cs" />
|
||||
<Compile Include="Forms\CreateUserForm.cs" />
|
||||
<Compile Include="Handlers\WorkflowUserEventHandler.cs" />
|
||||
<Compile Include="Extensions\ModelStateDistionaryExtensions.cs" />
|
||||
<Compile Include="Migrations.cs" />
|
||||
<Compile Include="Events\UserContext.cs" />
|
||||
<Compile Include="Handlers\RegistrationSettingsPartHandler.cs" />
|
||||
@@ -211,7 +215,9 @@
|
||||
<Content Include="Views\LogOn.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Web.config" />
|
||||
<Content Include="Web.config">
|
||||
<SubType>Designer</SubType>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Styles\Web.config">
|
||||
@@ -236,6 +242,9 @@
|
||||
<ItemGroup>
|
||||
<Content Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Views\Account\ChangeExpiredPassword.cshtml" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
using Orchard.Localization;
|
||||
using Orchard.Security;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Orchard.Users.Services {
|
||||
public interface IUserService : IDependency {
|
||||
bool VerifyUserUnicity(string userName, string email);
|
||||
@@ -13,5 +16,7 @@ namespace Orchard.Users.Services {
|
||||
|
||||
string CreateNonce(IUser user, TimeSpan delay);
|
||||
bool DecryptNonce(string challengeToken, out string username, out DateTime validateByUtc);
|
||||
|
||||
bool PasswordMeetsPolicies(string password, out IDictionary<string, LocalizedString> validationErrors);
|
||||
}
|
||||
}
|
||||
@@ -1,21 +1,21 @@
|
||||
using System;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.DisplayManagement;
|
||||
using Orchard.Environment.Configuration;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Logging;
|
||||
using Orchard.Messaging.Services;
|
||||
using Orchard.Security;
|
||||
using Orchard.Services;
|
||||
using Orchard.Users.Events;
|
||||
using Orchard.Users.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Web.Security;
|
||||
using Orchard.DisplayManagement;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Logging;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Security;
|
||||
using Orchard.Users.Events;
|
||||
using Orchard.Users.Models;
|
||||
using Orchard.Messaging.Services;
|
||||
using System.Collections.Generic;
|
||||
using Orchard.Services;
|
||||
using System.Web.Helpers;
|
||||
using Orchard.Environment.Configuration;
|
||||
using Orchard.Environment.Extensions;
|
||||
using System.Web.Security;
|
||||
|
||||
namespace Orchard.Users.Services {
|
||||
[OrchardSuppressDependency("Orchard.Security.NullMembershipService")]
|
||||
@@ -56,11 +56,9 @@ namespace Orchard.Users.Services {
|
||||
public ILogger Logger { get; set; }
|
||||
public Localizer T { get; set; }
|
||||
|
||||
public MembershipSettings GetSettings() {
|
||||
var settings = new MembershipSettings();
|
||||
// accepting defaults
|
||||
return settings;
|
||||
}
|
||||
public IMembershipSettings GetSettings(){
|
||||
return _orchardServices.WorkContext.CurrentSite.As<RegistrationSettingsPart>();
|
||||
}
|
||||
|
||||
public IUser CreateUser(CreateUserParams createUserParams) {
|
||||
Logger.Information("CreateUser {0} {1}", createUserParams.Username, createUserParams.Email);
|
||||
@@ -157,6 +155,10 @@ namespace Orchard.Users.Services {
|
||||
return user;
|
||||
}
|
||||
|
||||
public bool PasswordIsExpired(IUser user, int days){
|
||||
return user.As<UserPart>().LastPasswordChangeUtc.Value.AddDays(days) < _clock.UtcNow;
|
||||
}
|
||||
|
||||
public void SetPassword(IUser user, string password) {
|
||||
if (!user.Is<UserPart>())
|
||||
throw new InvalidCastException();
|
||||
@@ -176,6 +178,7 @@ namespace Orchard.Users.Services {
|
||||
default:
|
||||
throw new ApplicationException(T("Unexpected password format value").ToString());
|
||||
}
|
||||
userPart.LastPasswordChangeUtc = _clock.UtcNow;
|
||||
}
|
||||
|
||||
private bool ValidatePassword(UserPart userPart, string password) {
|
||||
|
||||
@@ -1,19 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.DisplayManagement;
|
||||
using Orchard.Environment.Configuration;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Logging;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Settings;
|
||||
using Orchard.Users.Models;
|
||||
using Orchard.Security;
|
||||
using System.Xml.Linq;
|
||||
using Orchard.Services;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using Orchard.Messaging.Services;
|
||||
using Orchard.Environment.Configuration;
|
||||
using Orchard.Security;
|
||||
using Orchard.Services;
|
||||
using Orchard.Settings;
|
||||
using Orchard.Users.Constants;
|
||||
using Orchard.Users.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Orchard.Users.Services {
|
||||
public class UserService : IUserService {
|
||||
@@ -38,8 +40,8 @@ namespace Orchard.Users.Services {
|
||||
IEncryptionService encryptionService,
|
||||
IShapeFactory shapeFactory,
|
||||
IShapeDisplay shapeDisplay,
|
||||
ISiteService siteService
|
||||
) {
|
||||
ISiteService siteService) {
|
||||
|
||||
_contentManager = contentManager;
|
||||
_membershipService = membershipService;
|
||||
_clock = clock;
|
||||
@@ -48,7 +50,9 @@ namespace Orchard.Users.Services {
|
||||
_shapeFactory = shapeFactory;
|
||||
_shapeDisplay = shapeDisplay;
|
||||
_siteService = siteService;
|
||||
|
||||
Logger = NullLogger.Instance;
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
|
||||
public ILogger Logger { get; set; }
|
||||
@@ -194,5 +198,42 @@ namespace Orchard.Users.Services {
|
||||
|
||||
return user;
|
||||
}
|
||||
|
||||
public bool PasswordMeetsPolicies(string password, out IDictionary<string, LocalizedString> validationErrors) {
|
||||
validationErrors = new Dictionary<string, LocalizedString>();
|
||||
var settings = _siteService.GetSiteSettings().As<RegistrationSettingsPart>();
|
||||
|
||||
if (string.IsNullOrEmpty(password)) {
|
||||
validationErrors.Add(UserPasswordValidationResults.PasswordIsTooShort,
|
||||
T("The password can't be empty."));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (password.Length < settings.GetMinimumPasswordLength()) {
|
||||
validationErrors.Add(UserPasswordValidationResults.PasswordIsTooShort,
|
||||
T("You must specify a password of {0} or more characters.", settings.MinimumPasswordLength));
|
||||
}
|
||||
|
||||
if (settings.EnableCustomPasswordPolicy) {
|
||||
if (settings.EnablePasswordNumberRequirement && !Regex.Match(password, "[0-9]").Success) {
|
||||
validationErrors.Add(UserPasswordValidationResults.PasswordDoesNotContainNumbers,
|
||||
T("The password must contain at least one number."));
|
||||
}
|
||||
if (settings.EnablePasswordUppercaseRequirement && !password.Any(c => char.IsUpper(c))) {
|
||||
validationErrors.Add(UserPasswordValidationResults.PasswordDoesNotContainUppercase,
|
||||
T("The password must contain at least one uppercase letter."));
|
||||
}
|
||||
if (settings.EnablePasswordLowercaseRequirement && !password.Any(c => char.IsLower(c))) {
|
||||
validationErrors.Add(UserPasswordValidationResults.PasswordDoesNotContainLowercase,
|
||||
T("The password must contain at least one lowercase letter."));
|
||||
}
|
||||
if (settings.EnablePasswordSpecialRequirement && !Regex.Match(password, "[^a-zA-Z0-9]").Success) {
|
||||
validationErrors.Add(UserPasswordValidationResults.PasswordDoesNotContainSpecialCharacters,
|
||||
T("The password must contain at least one special character."));
|
||||
}
|
||||
}
|
||||
|
||||
return validationErrors.Count == 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,6 @@ namespace Orchard.Users.ViewModels {
|
||||
public string Email { get; set; }
|
||||
|
||||
[Required, DataType(DataType.Password)]
|
||||
[StringLength(50, MinimumLength = 7)]
|
||||
public string Password { get; set; }
|
||||
|
||||
[Required, DataType(DataType.Password)]
|
||||
|
||||
@@ -7,7 +7,6 @@ namespace Orchard.Users.ViewModels
|
||||
[OrchardFeature("Orchard.Users.EditPasswordByAdmin")]
|
||||
public class UserEditPasswordViewModel {
|
||||
[DataType(DataType.Password)]
|
||||
[StringLength(50, MinimumLength = 7)]
|
||||
public string Password { get; set; }
|
||||
|
||||
[DataType(DataType.Password)]
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
@model dynamic
|
||||
<h1>@Html.TitleForPage(T("Change Expired Password"))</h1>
|
||||
<p>@T("Your password has expired. Use the form below to change your password.")</p>
|
||||
<p>@T.Plural("The password can't be empty.", "Passwords are required to be a minimum of {0} characters in length.", (int)Model.PasswordLength)</p>
|
||||
@Html.ValidationSummary(T("Password change was unsuccessful. Please correct the errors and try again.").Text)
|
||||
@using (Html.BeginFormAntiForgeryPost()) {
|
||||
<fieldset>
|
||||
<legend>@T("Account Information")</legend>
|
||||
<div>
|
||||
@T("Username: {0}", Model.Username)
|
||||
</div>
|
||||
<div>
|
||||
<label for="currentPassword">@T("Current Password:")</label>
|
||||
@Html.Password("currentPassword")
|
||||
@Html.ValidationMessage("currentPassword")
|
||||
</div>
|
||||
<div>
|
||||
<label for="newPassword">@T("New Password:")</label>
|
||||
@Html.Password("newPassword")
|
||||
@Html.ValidationMessage("newPassword")
|
||||
</div>
|
||||
<div>
|
||||
<label for="confirmPassword">@T("Confirm New Password:")</label>
|
||||
@Html.Password("confirmPassword")
|
||||
@Html.ValidationMessage("confirmPassword")
|
||||
</div>
|
||||
<div>
|
||||
<button class="primaryAction" type="submit">@T("Change Password")</button>
|
||||
</div>
|
||||
</fieldset>
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
@model dynamic
|
||||
<h1>@Html.TitleForPage(T("Change Password").ToString()) </h1>
|
||||
<p>@T("Use the form below to change your password.")</p>
|
||||
<p>@T("New passwords are required to be a minimum of {0} characters in length.", ViewData["PasswordLength"]) </p>
|
||||
<p>@T.Plural("The password can't be empty.", "New passwords are required to be a minimum of {0} characters in length.", (int)ViewData["PasswordLength"])</p>
|
||||
@Html.ValidationSummary(T("Password change was unsuccessful. Please correct the errors and try again.").ToString())
|
||||
@using (Html.BeginFormAntiForgeryPost()) {
|
||||
<fieldset>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
@model dynamic
|
||||
<h1>@Html.TitleForPage(T("Change Password").ToString()) </h1>
|
||||
<p>@T("Use the form below to change your password.")</p>
|
||||
<p>@T("New passwords are required to be a minimum of {0} characters in length.", ViewData["PasswordLength"]) </p>
|
||||
<p>@T.Plural("The password can't be empty.", "New passwords are required to be a minimum of {0} characters in length.", (int)ViewData["PasswordLength"])</p>
|
||||
@Html.ValidationSummary(T("Password change was unsuccessful. Please correct the errors and try again.").ToString())
|
||||
@using (Html.BeginFormAntiForgeryPost()) {
|
||||
<fieldset>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
@model Orchard.Users.Models.RegistrationSettingsPart
|
||||
@using Orchard.Messaging.Services;
|
||||
@using System.Web.Security;
|
||||
|
||||
@{
|
||||
var messageManager = WorkContext.Resolve<IMessageManager>();
|
||||
@@ -9,13 +10,69 @@
|
||||
<fieldset>
|
||||
<legend>@T("Users")</legend>
|
||||
<div>
|
||||
@Html.EditorFor(m => m.UsersCanRegister)
|
||||
<label class="forcheckbox" for="@Html.FieldIdFor( m => m.UsersCanRegister)">@T("Users can create new accounts on the site")</label>
|
||||
@Html.EditorFor(m => m.UsersCanRegister)
|
||||
<label class="forcheckbox" for="@Html.FieldIdFor(m => m.UsersCanRegister)">@T("Users can create new accounts on the site")</label>
|
||||
</div>
|
||||
<div>
|
||||
@Html.EditorFor(m => m.EnableCustomPasswordPolicy)
|
||||
<label class="forcheckbox" for="@Html.FieldIdFor(m => m.EnableCustomPasswordPolicy)">@T("Passwords must meet custom requirements")</label>
|
||||
<div data-controllerid="@Html.FieldIdFor(m => m.EnableCustomPasswordPolicy)" style="margin-left: 30px;">
|
||||
<div>
|
||||
<input type="checkbox" value="true" class="check-box" id="@Html.FieldIdFor(m => m.EnablePasswordLowercaseRequirement)"
|
||||
name="@Html.FieldNameFor(m => m.EnablePasswordLowercaseRequirement)" @(Model.EnablePasswordLowercaseRequirement && Model.EnableCustomPasswordPolicy ? "checked=\"checked\"" : "") />
|
||||
<input name="@Html.FieldNameFor(m => m.EnablePasswordLowercaseRequirement)" type="hidden" value="false">
|
||||
<label class="forcheckbox" for="@Html.FieldIdFor(m => m.EnablePasswordLowercaseRequirement)">@T("Password must contain at least one lower case letter (a-z)")</label>
|
||||
</div>
|
||||
<div>
|
||||
<input type="checkbox" value="true" class="check-box" id="@Html.FieldIdFor(m => m.EnablePasswordUppercaseRequirement)"
|
||||
name="@Html.FieldNameFor(m => m.EnablePasswordUppercaseRequirement)" @(Model.EnablePasswordUppercaseRequirement && Model.EnableCustomPasswordPolicy ? "checked=\"checked\"" : "") />
|
||||
<input name="@Html.FieldNameFor(m => m.EnablePasswordUppercaseRequirement)" type="hidden" value="false">
|
||||
<label class="forcheckbox" for="@Html.FieldIdFor(m => m.EnablePasswordUppercaseRequirement)">@T("Password must contain at least one upper case letter (A-Z)")</label>
|
||||
</div>
|
||||
<div>
|
||||
<input type="checkbox" value="true" class="check-box" id="@Html.FieldIdFor(m => m.EnablePasswordNumberRequirement)"
|
||||
name="@Html.FieldNameFor(m => m.EnablePasswordNumberRequirement)" @(Model.EnablePasswordNumberRequirement && Model.EnableCustomPasswordPolicy ? "checked=\"checked\"" : "") />
|
||||
<input name="@Html.FieldNameFor(m => m.EnablePasswordNumberRequirement)" type="hidden" value="false">
|
||||
<label class="forcheckbox" for="@Html.FieldIdFor(m => m.EnablePasswordNumberRequirement)">@T("Password must contain at least one number (0-9)")</label>
|
||||
</div>
|
||||
<div>
|
||||
<input type="checkbox" value="true" class="check-box" id="@Html.FieldIdFor(m => m.EnablePasswordSpecialRequirement)"
|
||||
name="@Html.FieldNameFor(m => m.EnablePasswordSpecialRequirement)" @(Model.EnablePasswordSpecialRequirement && Model.EnableCustomPasswordPolicy ? "checked=\"checked\"" : "") />
|
||||
<input name="@Html.FieldNameFor(m => m.EnablePasswordSpecialRequirement)" type="hidden" value="false">
|
||||
<label class="forcheckbox" for="@Html.FieldIdFor(m => m.EnablePasswordSpecialRequirement)">@T("Password must contain at least one special character")</label>
|
||||
</div>
|
||||
<div>
|
||||
<label for="@Html.FieldIdFor(m => m.MinimumPasswordLength)">@T("Minimum Password length")</label>
|
||||
@Html.TextBoxFor(m => m.MinimumPasswordLength, new { @class = "text medium", @Value = Model.MinimumPasswordLength })
|
||||
@Html.ValidationMessage("MinimumPasswordLength", "*")
|
||||
</div>
|
||||
<div>
|
||||
<input type="checkbox" value="true" class="check-box" id="@Html.FieldIdFor(m => m.EnablePasswordExpiration)"
|
||||
name="@Html.FieldNameFor(m => m.EnablePasswordExpiration)" @(Model.EnablePasswordExpiration && Model.EnableCustomPasswordPolicy ? "checked=\"checked\"" : "") />
|
||||
<input name="@Html.FieldNameFor(m => m.EnablePasswordExpiration)" type="hidden" value="false">
|
||||
<label class="forcheckbox" for="@Html.FieldIdFor(m => m.EnablePasswordExpiration)">@T("Password expires after a time period (30 days by default)")</label>
|
||||
</div>
|
||||
<div data-controllerid="@Html.FieldIdFor(m => m.EnablePasswordExpiration)" style="margin-left: 30px;">
|
||||
<label for="@Html.FieldIdFor(m => m.PasswordExpirationTimeInDays)">@T("Password expiration period in days")</label>
|
||||
@Html.TextBoxFor(m => m.PasswordExpirationTimeInDays, new { @class = "text medium", @Value = Model.PasswordExpirationTimeInDays })
|
||||
@Html.ValidationMessage("PasswordExpirationTimeInDays", "*")
|
||||
</div>
|
||||
<div>
|
||||
<label for="@Html.FieldIdFor(m => m.PasswordFormat)">@T("Password format")</label>
|
||||
@Html.DropDownListFor(m => m.PasswordFormat, new SelectList(new[]
|
||||
{
|
||||
new SelectListItem { Text = T("Clear").Text, Value = MembershipPasswordFormat.Clear.ToString() },
|
||||
new SelectListItem { Text = T("Hashed").Text, Value = MembershipPasswordFormat.Hashed.ToString(), Selected = true },
|
||||
new SelectListItem { Text = T("Encrypted").Text, Value = MembershipPasswordFormat.Encrypted.ToString() }
|
||||
}, "Value", "Text"))
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<input type="checkbox" value="true" class="check-box" id="@Html.FieldIdFor(m => m.EnableLostPassword)" name="@Html.FieldNameFor(m => m.EnableLostPassword)" @(Model.EnableLostPassword ? "checked=\"checked\"" : "") @(emailEnabled ? "" : "disabled=\"disabled\"")/>
|
||||
<input name="@Html.FieldNameFor(m => m.EnableLostPassword)" type="hidden" value="false">
|
||||
<label class="forcheckbox" for="@Html.FieldIdFor( m => m.EnableLostPassword)">@T("Display a link to enable users to reset their password")</label>
|
||||
<label class="forcheckbox" for="@Html.FieldIdFor(m => m.EnableLostPassword)">@T("Display a link to enable users to reset their password")</label>
|
||||
|
||||
@if(!emailEnabled) {
|
||||
<div class="message message-Warning">@T("This option is available when an email module is activated.")</div>
|
||||
@@ -24,31 +81,31 @@
|
||||
<div>
|
||||
<input type="checkbox" value="true" class="check-box" id="@Html.FieldIdFor(m => m.UsersMustValidateEmail)" name="@Html.FieldNameFor(m => m.UsersMustValidateEmail)" @(Model.UsersMustValidateEmail ? "checked=\"checked\"" : "") @(emailEnabled ? "" : "disabled=\"disabled\"")/>
|
||||
<input name="@Html.FieldNameFor(m => m.UsersMustValidateEmail)" type="hidden" value="false">
|
||||
<label class="forcheckbox" for="@Html.FieldIdFor( m => m.UsersMustValidateEmail)">@T("Users must verify their email address")</label>
|
||||
<label class="forcheckbox" for="@Html.FieldIdFor(m => m.UsersMustValidateEmail)">@T("Users must verify their email address")</label>
|
||||
|
||||
@if(!emailEnabled) {
|
||||
<div class="message message-Warning">@T("This option is available when an email module is activated.")</div>
|
||||
}
|
||||
</div>
|
||||
<div data-controllerid="@Html.FieldIdFor(m => m.UsersMustValidateEmail)">
|
||||
<label for="@Html.FieldIdFor( m => m.ValidateEmailRegisteredWebsite)">@T("Website public name")</label>
|
||||
<label for="@Html.FieldIdFor(m => m.ValidateEmailRegisteredWebsite)">@T("Website public name")</label>
|
||||
@Html.TextBoxFor(m => m.ValidateEmailRegisteredWebsite, new { @class = "text medium" } )
|
||||
@Html.ValidationMessage("ValidateEmailRegisteredWebsite", "*")
|
||||
<span class="hint">@T("The name of your website as it will appear in the verification e-mail.")</span>
|
||||
|
||||
<label for="@Html.FieldIdFor( m => m.ValidateEmailContactEMail)">@T("Contact Us E-Mail address")</label>
|
||||
<label for="@Html.FieldIdFor(m => m.ValidateEmailContactEMail)">@T("Contact Us E-Mail address")</label>
|
||||
@Html.TextBoxFor(m => m.ValidateEmailContactEMail, new { @class = "text medium" } )
|
||||
@Html.ValidationMessage("ValidateEmailContactEMail", "*")
|
||||
<span class="hint">@T("The e-mail address displayed in the verification e-mail for a Contact Us link. Leave empty for no link.")</span>
|
||||
</div>
|
||||
<div>
|
||||
@Html.EditorFor(m => m.UsersAreModerated)
|
||||
<label class="forcheckbox" for="@Html.FieldIdFor( m => m.UsersAreModerated)">@T("Users must be approved before they can log in")</label>
|
||||
<label class="forcheckbox" for="@Html.FieldIdFor(m => m.UsersAreModerated)">@T("Users must be approved before they can log in")</label>
|
||||
</div>
|
||||
<div data-controllerid="@Html.FieldIdFor(m => m.UsersAreModerated)">
|
||||
<input type="checkbox" value="true" class="check-box" id="@Html.FieldIdFor(m => m.NotifyModeration)" name="@Html.FieldNameFor(m => m.NotifyModeration)" @(Model.NotifyModeration ? "checked=\"checked\"" : "") @(emailEnabled ? "" : "disabled=\"disabled\"")/>
|
||||
<input name="@Html.FieldNameFor(m => m.NotifyModeration)" type="hidden" value="false">
|
||||
<label class="forcheckbox" for="@Html.FieldIdFor( m => m.NotifyModeration)">@T("Send a notification when a user needs moderation")</label>
|
||||
<label class="forcheckbox" for="@Html.FieldIdFor(m => m.NotifyModeration)">@T("Send a notification when a user needs moderation")</label>
|
||||
|
||||
@if(!emailEnabled) {
|
||||
<div class="message message-Warning">@T("This option is available when an email module is activated.")</div>
|
||||
@@ -56,7 +113,7 @@
|
||||
|
||||
</div>
|
||||
<div data-controllerid="@Html.FieldIdFor(m => m.NotifyModeration)">
|
||||
<label for="@Html.FieldIdFor( m => m.NotificationsRecipients)">@T("Moderators")</label>
|
||||
<label for="@Html.FieldIdFor(m => m.NotificationsRecipients)">@T("Moderators")</label>
|
||||
@Html.TextBoxFor(m => m.NotificationsRecipients, new { @class = "text medium" } )
|
||||
@Html.ValidationMessage("NotificationsRecipients", "*")
|
||||
<span class="hint">@T("The usernames to send the notifications to (e.g., \"admin, user1, ...\").")</span>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<h1>@Html.TitleForPage(T("Create a New Account").ToString())</h1>
|
||||
<p>@T("Use the form below to create a new account.")</p>
|
||||
<p>@T("Passwords are required to be a minimum of {0} characters in length.", ViewData["PasswordLength"])</p>
|
||||
<p>@T.Plural("The password can't be empty.", "Passwords are required to be a minimum of {0} characters in length.", (int)ViewData["PasswordLength"])</p>
|
||||
@Html.ValidationSummary(T("Account creation was unsuccessful. Please correct the errors and try again.").ToString())
|
||||
@using (Html.BeginFormAntiForgeryPost(Url.Action("Register", new { ReturnUrl = Request.QueryString["ReturnUrl"] }))) {
|
||||
<fieldset>
|
||||
@@ -13,7 +13,7 @@
|
||||
<div>
|
||||
<label for="email">@T("Email:")</label>
|
||||
@Html.TextBox("email")
|
||||
@Html.ValidationMessage("email")
|
||||
@Html.ValidationMessage("email")
|
||||
</div>
|
||||
<div>
|
||||
<label for="password">@T("Password:")</label>
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
<add assembly="System.Web.WebPages, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
|
||||
<add assembly="Orchard.Framework" />
|
||||
<add assembly="Orchard.Core" />
|
||||
<add assembly="System.Web.ApplicationServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
|
||||
</assemblies>
|
||||
</compilation>
|
||||
</system.web>
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
@using Orchard.Localization
|
||||
|
||||
@{
|
||||
var propertyName = Model.PropertyName != null ? (string)Model.PropertyName : "Text";
|
||||
var shellDescriptor = WorkContext.Resolve<ShellDescriptor>();
|
||||
}
|
||||
|
||||
@@ -11,7 +12,7 @@
|
||||
var mediaLibraryEnabled = @(shellDescriptor.Features.Any(x => x.Name == "Orchard.MediaLibrary") ? "true" : "false");
|
||||
var directionality = '@WorkContext.GetTextDirection((IContent)Model.ContentItem)';
|
||||
var language = '@Model.Language';
|
||||
var autofocus = "@(Model.AutoFocus == true ? ViewData.TemplateInfo.GetFullHtmlFieldId("Text") : null)";
|
||||
var autofocus = "@(Model.AutoFocus == true ? ViewData.TemplateInfo.GetFullHtmlFieldId(propertyName) : null)";
|
||||
</script>
|
||||
|
||||
@{
|
||||
@@ -21,7 +22,7 @@
|
||||
Style.Require("OrchardTinyMce");
|
||||
}
|
||||
|
||||
@Html.TextArea("Text", (string)Model.Text, 25, 80,
|
||||
@Html.TextArea(propertyName, (string)Model.Text, 25, 80,
|
||||
new Dictionary<string,object> {
|
||||
{"class", "html tinymce"},
|
||||
{"data-mediapicker-uploadpath",Model.AddMediaPath},
|
||||
|
||||
@@ -58,12 +58,12 @@
|
||||
<HintPath>..\packages\log4net.2.0.3\lib\net40-full\log4net.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Owin, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Owin.3.0.0\lib\net45\Microsoft.Owin.dll</HintPath>
|
||||
<Reference Include="Microsoft.Owin, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Owin.3.0.1\lib\net45\Microsoft.Owin.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Owin.Host.SystemWeb, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Owin.Host.SystemWeb.3.0.0\lib\net45\Microsoft.Owin.Host.SystemWeb.dll</HintPath>
|
||||
<Reference Include="Microsoft.Owin.Host.SystemWeb, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Owin.Host.SystemWeb.3.0.1\lib\net45\Microsoft.Owin.Host.SystemWeb.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
|
||||
@@ -620,11 +620,11 @@ legend span {
|
||||
.bulk-actions label, .bulk-items h3, label.sub {
|
||||
display:inline;
|
||||
}
|
||||
label.bulk-filter {
|
||||
}
|
||||
label.bulk-order {
|
||||
text-transform:lowercase;
|
||||
}
|
||||
label.bulk-culture {
|
||||
text-transform:lowercase;
|
||||
}
|
||||
label span {
|
||||
font-weight:normal;
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
<add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
|
||||
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<add assembly="System.Data.Entity.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<add assembly="Microsoft.Owin.Host.SystemWeb, Version=3.0.0.0" />
|
||||
<add assembly="Microsoft.Owin.Host.SystemWeb, Version=3.0.1.0" />
|
||||
<add assembly="System.Data.Services.Client, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<add assembly="System.Numerics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<add assembly="System.Transactions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
@@ -233,6 +233,26 @@
|
||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Microsoft.Owin.Host.SystemWeb" publicKeyToken="31bf3856ad364e35" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Microsoft.IdentityModel.Protocol.Extensions" publicKeyToken="31bf3856ad364e35" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-1.0.2.33" newVersion="1.0.2.33" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.IdentityModel.Tokens.Jwt" publicKeyToken="31bf3856ad364e35" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="4.0.20622.1351" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Microsoft.IdentityModel.Protocol.Extensions" publicKeyToken="31bf3856ad364e35" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-1.0.2.33" newVersion="1.0.2.33" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
<package id="Microsoft.AspNet.Mvc" version="5.2.3" targetFramework="net452" />
|
||||
<package id="Microsoft.AspNet.Razor" version="3.2.3" targetFramework="net452" />
|
||||
<package id="Microsoft.AspNet.WebPages" version="3.2.3" targetFramework="net452" />
|
||||
<package id="Microsoft.Owin" version="3.0.0" targetFramework="net452" />
|
||||
<package id="Microsoft.Owin.Host.SystemWeb" version="3.0.0" targetFramework="net452" />
|
||||
<package id="Microsoft.Owin" version="3.0.1" targetFramework="net452" />
|
||||
<package id="Microsoft.Owin.Host.SystemWeb" version="3.0.1" targetFramework="net452" />
|
||||
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net452" />
|
||||
<package id="MySql.Data" version="6.7.9" targetFramework="net452" />
|
||||
<package id="Newtonsoft.Json" version="7.0.1" targetFramework="net452" />
|
||||
|
||||
@@ -278,6 +278,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Orchard.Resources", "Orchar
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Orchard.Azure.Tests", "Orchard.Azure.Tests\Orchard.Azure.Tests.csproj", "{1CC62F45-E6FF-43D5-84BF-509A1085D994}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Orchard.Azure.Authentication", "Orchard.Web\Modules\Orchard.Azure.Authentication\Orchard.Azure.Authentication.csproj", "{60D63D66-E88E-4D07-82EE-C1561903A73E}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
CodeCoverage|Any CPU = CodeCoverage|Any CPU
|
||||
@@ -1114,6 +1116,16 @@ Global
|
||||
{1CC62F45-E6FF-43D5-84BF-509A1085D994}.FxCop|Any CPU.Build.0 = Release|Any CPU
|
||||
{1CC62F45-E6FF-43D5-84BF-509A1085D994}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1CC62F45-E6FF-43D5-84BF-509A1085D994}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{60D63D66-E88E-4D07-82EE-C1561903A73E}.CodeCoverage|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{60D63D66-E88E-4D07-82EE-C1561903A73E}.CodeCoverage|Any CPU.Build.0 = Release|Any CPU
|
||||
{60D63D66-E88E-4D07-82EE-C1561903A73E}.Coverage|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{60D63D66-E88E-4D07-82EE-C1561903A73E}.Coverage|Any CPU.Build.0 = Release|Any CPU
|
||||
{60D63D66-E88E-4D07-82EE-C1561903A73E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{60D63D66-E88E-4D07-82EE-C1561903A73E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{60D63D66-E88E-4D07-82EE-C1561903A73E}.FxCop|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{60D63D66-E88E-4D07-82EE-C1561903A73E}.FxCop|Any CPU.Build.0 = Release|Any CPU
|
||||
{60D63D66-E88E-4D07-82EE-C1561903A73E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{60D63D66-E88E-4D07-82EE-C1561903A73E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
@@ -1202,6 +1214,7 @@ Global
|
||||
{98251EAE-A41B-47B2-AA91-E28B8482DA70} = {E9C9F120-07BA-4DFB-B9C3-3AFB9D44C9D5}
|
||||
{D4E8F7C8-2DB2-4C50-A422-DA1DF1E3CC73} = {E9C9F120-07BA-4DFB-B9C3-3AFB9D44C9D5}
|
||||
{1CC62F45-E6FF-43D5-84BF-509A1085D994} = {74E681ED-FECC-4034-B9BD-01B0BB1BDECA}
|
||||
{60D63D66-E88E-4D07-82EE-C1561903A73E} = {E9C9F120-07BA-4DFB-B9C3-3AFB9D44C9D5}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
EnterpriseLibraryConfigurationToolBinariesPath = packages\TransientFaultHandling.Core.5.1.1209.1\lib\NET4
|
||||
|
||||
@@ -162,7 +162,21 @@ namespace Orchard.ContentManagement.Drivers {
|
||||
}
|
||||
|
||||
private ContentShapeResult ContentShapeImplementation(string shapeType, string differentiator, Func<BuildShapeContext, object> shapeBuilder) {
|
||||
return new ContentShapeResult(shapeType, Prefix, ctx => AddAlternates(shapeBuilder(ctx), ctx, differentiator)).Differentiator(differentiator);
|
||||
var result = new ContentShapeResult(shapeType, Prefix, ctx => {
|
||||
var shape = shapeBuilder(ctx);
|
||||
|
||||
if (shape == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return AddAlternates(shape, ctx, differentiator);
|
||||
});
|
||||
|
||||
if (result == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return result.Differentiator(differentiator);
|
||||
}
|
||||
|
||||
private static object AddAlternates(dynamic shape, BuildShapeContext ctx, string differentiator) {
|
||||
|
||||
@@ -133,8 +133,8 @@ namespace Orchard.ContentManagement {
|
||||
|
||||
return EncodeQuotes(Convert.ToString(value, CultureInfo.InvariantCulture));
|
||||
case TypeCode.DateTime:
|
||||
// convert the date time to a valid string representation for Hql
|
||||
var sortableDateTime = ((DateTime)value).ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);
|
||||
// convert the date time to a valid string representation for Hql (ISO 8601 format, which is language neutral)
|
||||
var sortableDateTime = ((DateTime)value).ToString("yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture);
|
||||
return quoteStrings ? String.Concat("'", EncodeQuotes(sortableDateTime), "'") : sortableDateTime;
|
||||
}
|
||||
|
||||
|
||||
@@ -85,9 +85,16 @@ namespace Orchard.Data.Migration {
|
||||
var schemaBuilder = new SchemaBuilder(_dataMigrationInterpreter);
|
||||
var distributedLockSchemaBuilder = new DistributedLockSchemaBuilder(_shellSettings, schemaBuilder);
|
||||
if (!distributedLockSchemaBuilder.SchemaExists()) {
|
||||
|
||||
// Workaround to avoid some Transaction issue for PostgreSQL.
|
||||
_transactionManager.RequireNew();
|
||||
if (_shellSettings.DataProvider.Equals("PostgreSql", StringComparison.OrdinalIgnoreCase)) {
|
||||
_transactionManager.RequireNew();
|
||||
distributedLockSchemaBuilder.CreateSchema();
|
||||
return;
|
||||
}
|
||||
|
||||
distributedLockSchemaBuilder.CreateSchema();
|
||||
_transactionManager.RequireNew();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Globalization;
|
||||
using System.Runtime.Serialization;
|
||||
using Orchard.Localization;
|
||||
|
||||
namespace Orchard.Mvc.DataAnnotations {
|
||||
public class LocalizedRangeAttribute : RangeAttribute {
|
||||
public LocalizedRangeAttribute(RangeAttribute attribute, Localizer t)
|
||||
: base(attribute.OperandType, new FormatterConverter().ToString(attribute.Minimum), new FormatterConverter().ToString(attribute.Maximum)) {
|
||||
: base(attribute.OperandType, Convert.ToString(attribute.Minimum, CultureInfo.CurrentCulture), Convert.ToString(attribute.Maximum, CultureInfo.CurrentCulture)) {
|
||||
if ( !String.IsNullOrEmpty(attribute.ErrorMessage) )
|
||||
ErrorMessage = attribute.ErrorMessage;
|
||||
|
||||
|
||||
@@ -84,8 +84,8 @@
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="Microsoft.Owin, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Owin.3.0.0\lib\net45\Microsoft.Owin.dll</HintPath>
|
||||
<Reference Include="Microsoft.Owin, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Owin.3.0.1\lib\net45\Microsoft.Owin.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
@@ -209,6 +209,7 @@
|
||||
<Compile Include="Reports\Services\ReportsCoordinator.cs" />
|
||||
<Compile Include="Reports\Services\ReportsManager.cs" />
|
||||
<Compile Include="Reports\Services\ReportsPersister.cs" />
|
||||
<Compile Include="Security\IMembershipSettings.cs" />
|
||||
<Compile Include="Security\IMembershipValidationService.cs" />
|
||||
<Compile Include="Localization\Services\ILocalizationStreamParser.cs" />
|
||||
<Compile Include="Localization\Services\LocalizationStreamParser.cs" />
|
||||
@@ -939,7 +940,6 @@
|
||||
<Compile Include="Mvc\Wrappers\HttpResponseBaseWrapper.cs" />
|
||||
<Compile Include="OrchardException.cs" />
|
||||
<Compile Include="Security\IAuthorizationServiceEventHandler.cs" />
|
||||
<Compile Include="Security\MembershipSettings.cs" />
|
||||
<Compile Include="Security\StandardPermissions.cs" />
|
||||
<Compile Include="Security\OrchardSecurityException.cs" />
|
||||
<Compile Include="Tasks\Scheduling\IPublishingTaskManager.cs" />
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
namespace Orchard.Security {
|
||||
public interface IMembershipService : IDependency {
|
||||
MembershipSettings GetSettings();
|
||||
IMembershipSettings GetSettings();
|
||||
|
||||
IUser CreateUser(CreateUserParams createUserParams);
|
||||
IUser GetUser(string username);
|
||||
IUser ValidateUser(string userNameOrEmail, string password);
|
||||
void SetPassword(IUser user, string password);
|
||||
|
||||
bool PasswordIsExpired(IUser user, int days);
|
||||
}
|
||||
}
|
||||
|
||||
23
src/Orchard/Security/IMembershipSettings.cs
Normal file
23
src/Orchard/Security/IMembershipSettings.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using System.Web.Security;
|
||||
|
||||
namespace Orchard.Security {
|
||||
public interface IMembershipSettings {
|
||||
bool UsersCanRegister { get; set; }
|
||||
bool UsersMustValidateEmail { get; set; }
|
||||
string ValidateEmailRegisteredWebsite { get; set; }
|
||||
string ValidateEmailContactEMail { get; set; }
|
||||
bool UsersAreModerated { get; set; }
|
||||
bool NotifyModeration { get; set; }
|
||||
string NotificationsRecipients { get; set; }
|
||||
bool EnableLostPassword { get; set; }
|
||||
bool EnableCustomPasswordPolicy { get; set; }
|
||||
int MinimumPasswordLength { get; set; }
|
||||
bool EnablePasswordUppercaseRequirement { get; set; }
|
||||
bool EnablePasswordLowercaseRequirement { get; set; }
|
||||
bool EnablePasswordNumberRequirement { get; set; }
|
||||
bool EnablePasswordSpecialRequirement { get; set; }
|
||||
bool EnablePasswordExpiration { get; set; }
|
||||
int PasswordExpirationTimeInDays { get; set; }
|
||||
MembershipPasswordFormat PasswordFormat { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
using System.Web.Security;
|
||||
|
||||
namespace Orchard.Security {
|
||||
public class MembershipSettings {
|
||||
public MembershipSettings() {
|
||||
EnablePasswordRetrieval = false;
|
||||
EnablePasswordReset = true;
|
||||
RequiresQuestionAndAnswer = true;
|
||||
RequiresUniqueEmail = true;
|
||||
MaxInvalidPasswordAttempts = 5;
|
||||
PasswordAttemptWindow = 10;
|
||||
MinRequiredPasswordLength = 7;
|
||||
MinRequiredNonAlphanumericCharacters = 1;
|
||||
PasswordStrengthRegularExpression = "";
|
||||
PasswordFormat = MembershipPasswordFormat.Hashed;
|
||||
}
|
||||
|
||||
public bool EnablePasswordRetrieval { get; set; }
|
||||
public bool EnablePasswordReset { get; set; }
|
||||
public bool RequiresQuestionAndAnswer { get; set; }
|
||||
public int MaxInvalidPasswordAttempts { get; set; }
|
||||
public int PasswordAttemptWindow { get; set; }
|
||||
public bool RequiresUniqueEmail { get; set; }
|
||||
public MembershipPasswordFormat PasswordFormat { get; set; }
|
||||
public int MinRequiredPasswordLength { get; set; }
|
||||
public int MinRequiredNonAlphanumericCharacters { get; set; }
|
||||
public string PasswordStrengthRegularExpression { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ namespace Orchard.Security {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public MembershipSettings GetSettings() {
|
||||
public IMembershipSettings GetSettings() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@@ -26,5 +26,9 @@ namespace Orchard.Security {
|
||||
public IUser ValidateUser(string userNameOrEmail, string password) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool PasswordIsExpired(IUser user, int weeks) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.3" targetFramework="net452" />
|
||||
<package id="Microsoft.AspNet.WebApi.WebHost" version="5.2.3" targetFramework="net452" />
|
||||
<package id="Microsoft.AspNet.WebPages" version="3.2.3" targetFramework="net452" />
|
||||
<package id="Microsoft.Owin" version="3.0.0" targetFramework="net452" />
|
||||
<package id="Microsoft.Owin" version="3.0.1" targetFramework="net452" />
|
||||
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net452" />
|
||||
<package id="Newtonsoft.Json" version="7.0.1" targetFramework="net452" />
|
||||
<package id="NHibernate" version="4.0.1.4000" targetFramework="net452" />
|
||||
|
||||
Reference in New Issue
Block a user