diff --git a/src/Umbraco.Web.UI/App_Start/OwinStartup.cs b/src/Umbraco.Web.UI/App_Start/CustomUmbracoOwinStartup.cs similarity index 78% rename from src/Umbraco.Web.UI/App_Start/OwinStartup.cs rename to src/Umbraco.Web.UI/App_Start/CustomUmbracoOwinStartup.cs index 9279750636..6769b760a9 100644 --- a/src/Umbraco.Web.UI/App_Start/OwinStartup.cs +++ b/src/Umbraco.Web.UI/App_Start/CustomUmbracoOwinStartup.cs @@ -5,14 +5,19 @@ using Umbraco.Core.Security; using Umbraco.Web.Security.Identity; using Umbraco.Web.UI; -[assembly: OwinStartup("UmbracoStartup", typeof(OwinStartup))] +[assembly: OwinStartup("CustomUmbracoStartup", typeof(StandardUmbracoOwinStartup))] namespace Umbraco.Web.UI { /// - /// Default OWIN startup class as specified in appSettings + /// A custom way to configure OWIN for Umbraco /// - public class OwinStartup + /// + /// The startup type is specified in appSettings under owin:appStartup - change it to "CustomUmbracoStartup" to use this class + /// + /// This startup class would allow you to customize the Identity IUserStore and/or IUserManager for the Umbraco Backoffice + /// + public class CustomUmbracoOwinStartup { public void Configuration(IAppBuilder app) { @@ -22,14 +27,13 @@ namespace Umbraco.Web.UI ApplicationContext.Current, Core.Security.MembershipProviderExtensions.GetUsersMembershipProvider().AsUmbracoMembershipProvider()); - //Ensure owin is configured for Umbraco back office authentication. If you have any front-end OWIN - // cookie configuration, this must be declared after it. + //Ensure owin is configured for Umbraco back office authentication app .UseUmbracoBackOfficeCookieAuthentication() .UseUmbracoBackOfficeExternalCookieAuthentication(); /* - * Configure external logins: + * Configure external logins for the back office: * * Depending on the authentication sources you would like to enable, you will need to install * certain Nuget packages. @@ -47,7 +51,7 @@ namespace Umbraco.Web.UI * methods to suit your needs. */ - //app.ConfigureBackOfficeGoogleAuth("1072120697051-p41pro11srud3o3n90j7m00geq426jqt.apps.googleusercontent.com", "ak0msWvSE4w9nujcsfVy8_Y0"); + //app.ConfigureBackOfficeGoogleAuth("YOUR_APP_ID", "YOUR_APP_SECRET"); //app.ConfigureBackOfficeFacebookAuth("YOUR_APP_ID", "YOUR_APP_SECRET"); //app.ConfigureBackOfficeMicrosoftAuth("YOUR_CLIENT_ID", "YOUR_CLIENT_SECRET"); //app.ConfigureBackOfficeActiveDirectoryAuth("YOUR_TENANT", "YOUR_CLIENT_ID", "YOUR_POST_LOGIN_REDIRECT_URL", "YOUR_APP_KEY", "YOUR_AUTH_TYPE"); diff --git a/src/Umbraco.Web.UI/App_Start/StandardUmbracoOwinStartup.cs b/src/Umbraco.Web.UI/App_Start/StandardUmbracoOwinStartup.cs new file mode 100644 index 0000000000..a684efa2be --- /dev/null +++ b/src/Umbraco.Web.UI/App_Start/StandardUmbracoOwinStartup.cs @@ -0,0 +1,50 @@ +using Microsoft.Owin; +using Owin; +using Umbraco.Core; +using Umbraco.Core.Security; +using Umbraco.Web.Security.Identity; +using Umbraco.Web.UI; + +[assembly: OwinStartup("StandardUmbracoStartup", typeof(StandardUmbracoOwinStartup))] + +namespace Umbraco.Web.UI +{ + /// + /// The standard way to configure OWIN for Umbraco + /// + /// + /// The startup type is specified in appSettings under owin:appStartup - change it to "StandardUmbracoStartup" to use this class + /// + public class StandardUmbracoOwinStartup : DefaultUmbracoOwinStartup + { + public override void Configuration(IAppBuilder app) + { + //ensure the default options are configured + base.Configuration(app); + + /* + * Configure external logins for the back office: + * + * Depending on the authentication sources you would like to enable, you will need to install + * certain Nuget packages. + * + * For Google auth: Install-Package Microsoft.Owin.Security.Google + * For Facebook auth: Install-Package Microsoft.Owin.Security.Facebook + * For Microsoft auth: Install-Package Microsoft.Owin.Security.MicrosoftAccount + * + * There are many more providers such as Twitter, Yahoo, ActiveDirectory, etc... most information can + * be found here: http://www.asp.net/web-api/overview/security/external-authentication-services + * + * The source for these methods is located in ~/App_Code/IdentityAuthExtensions.cs, you will need to un-comment + * the methods that you would like to use. Each method contains documentation and links to + * documentation for reference. You can also tweak the code in those extension + * methods to suit your needs. + */ + + //app.ConfigureBackOfficeGoogleAuth("YOUR_APP_ID", "YOUR_APP_SECRET"); + //app.ConfigureBackOfficeFacebookAuth("YOUR_APP_ID", "YOUR_APP_SECRET"); + //app.ConfigureBackOfficeMicrosoftAuth("YOUR_CLIENT_ID", "YOUR_CLIENT_SECRET"); + //app.ConfigureBackOfficeActiveDirectoryAuth("YOUR_TENANT", "YOUR_CLIENT_ID", "YOUR_POST_LOGIN_REDIRECT_URL", "YOUR_APP_KEY", "YOUR_AUTH_TYPE"); + } + } +} \ No newline at end of file diff --git a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj index bc2269b1b2..ee56ec0fef 100644 --- a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj +++ b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj @@ -357,7 +357,8 @@ Properties\SolutionInfo.cs - + + loadStarterKits.ascx diff --git a/src/Umbraco.Web.UI/web.Template.Debug.config b/src/Umbraco.Web.UI/web.Template.Debug.config index 476d664dc5..58c400efb3 100644 --- a/src/Umbraco.Web.UI/web.Template.Debug.config +++ b/src/Umbraco.Web.UI/web.Template.Debug.config @@ -61,7 +61,7 @@ - + diff --git a/src/Umbraco.Web.UI/web.Template.config b/src/Umbraco.Web.UI/web.Template.config index 5357158046..825f2253d4 100644 --- a/src/Umbraco.Web.UI/web.Template.config +++ b/src/Umbraco.Web.UI/web.Template.config @@ -51,7 +51,7 @@ - + diff --git a/src/Umbraco.Web/DefaultUmbracoOwinStartup.cs b/src/Umbraco.Web/DefaultUmbracoOwinStartup.cs new file mode 100644 index 0000000000..16c2140a91 --- /dev/null +++ b/src/Umbraco.Web/DefaultUmbracoOwinStartup.cs @@ -0,0 +1,35 @@ +using Microsoft.Owin; +using Owin; +using Umbraco.Core; +using Umbraco.Core.Security; +using Umbraco.Web; +using Umbraco.Web.Security.Identity; + +[assembly: OwinStartup("DefaultUmbracoStartup", typeof(DefaultUmbracoOwinStartup))] + +namespace Umbraco.Web +{ + /// + /// The default way to configure OWIN for Umbraco + /// + /// + /// The startup type is specified in appSettings under owin:appStartup + /// + public class DefaultUmbracoOwinStartup + { + public virtual void Configuration(IAppBuilder app) + { + //Configure the Identity user manager for use with Umbraco Back office + // (EXPERT: an overload accepts a custom BackOfficeUserStore implementation) + app.ConfigureUserManagerForUmbracoBackOffice( + ApplicationContext.Current, + Core.Security.MembershipProviderExtensions.GetUsersMembershipProvider().AsUmbracoMembershipProvider()); + + //Ensure owin is configured for Umbraco back office authentication. If you have any front-end OWIN + // cookie configuration, this must be declared after it. + app + .UseUmbracoBackOfficeCookieAuthentication() + .UseUmbracoBackOfficeExternalCookieAuthentication(); + } + } +} diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index 45c4b51efb..ce591d090a 100644 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -306,6 +306,7 @@ +