Updates the owin startup classes - we now have a default one shipped as a DLL which will always execute based on the appSettings, then we can ship with 2 optional ones that people can learn and use from which just requires them to update the appSetting. Now to decide on how to ship these .cs files

This commit is contained in:
Shannon
2015-03-26 18:09:48 +11:00
parent 6efd14eff3
commit 394cab5ab4
7 changed files with 101 additions and 10 deletions

View File

@@ -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
{
/// <summary>
/// Default OWIN startup class as specified in appSettings
/// A custom way to configure OWIN for Umbraco
/// </summary>
public class OwinStartup
/// <remarks>
/// 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
/// </remarks>
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");

View File

@@ -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
{
/// <summary>
/// The standard way to configure OWIN for Umbraco
/// </summary>
/// <remarks>
/// The startup type is specified in appSettings under owin:appStartup - change it to "StandardUmbracoStartup" to use this class
/// </remarks>
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");
}
}
}

View File

@@ -357,7 +357,8 @@
<Compile Include="..\SolutionInfo.cs">
<Link>Properties\SolutionInfo.cs</Link>
</Compile>
<Compile Include="App_Start\OwinStartup.cs" />
<Compile Include="App_Start\CustomUmbracoOwinStartup.cs" />
<Compile Include="App_Start\StandardUmbracoOwinStartup.cs" />
<Compile Include="App_Start\UmbracoBackOfficeAuthExtensions.cs" />
<Compile Include="Umbraco\Install\Legacy\LoadStarterKits.ascx.cs">
<DependentUpon>loadStarterKits.ascx</DependentUpon>

View File

@@ -61,7 +61,7 @@
<add key="enableSimpleMembership" value="false" />
<add key="autoFormsAuthentication" value="false" />
<add key="log4net.Config" value="config\log4net.config" />
<add key="owin:appStartup" value="UmbracoStartup" xdt:Transform="InsertIfMissing" xdt:Locator="Match(key)" />
<add key="owin:appStartup" value="DefaultUmbracoStartup" xdt:Transform="InsertIfMissing" xdt:Locator="Match(key)" />
</appSettings>
<connectionStrings xdt:Transform="Remove" xdt:Locator="Condition(@configSource != '')" />

View File

@@ -51,7 +51,7 @@
<add key="autoFormsAuthentication" value="false" />
<add key="log4net.Config" value="config\log4net.config" />
<add key="owin:appStartup" value="UmbracoStartup" />
<add key="owin:appStartup" value="DefaultUmbracoStartup" />
</appSettings>
<connectionStrings>
<remove name="umbracoDbDSN" />

View File

@@ -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
{
/// <summary>
/// The default way to configure OWIN for Umbraco
/// </summary>
/// <remarks>
/// The startup type is specified in appSettings under owin:appStartup
/// </remarks>
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();
}
}
}

View File

@@ -306,6 +306,7 @@
</Compile>
<Compile Include="ApplicationContextExtensions.cs" />
<Compile Include="AreaRegistrationContextExtensions.cs" />
<Compile Include="DefaultUmbracoOwinStartup.cs" />
<Compile Include="IUmbracoContextAccessor.cs" />
<Compile Include="Models\ContentEditing\Relation.cs" />
<Compile Include="HtmlStringUtilities.cs" />