From ad92006f546e0ed3f950c60e4704d296babaa9c0 Mon Sep 17 00:00:00 2001 From: Shannon Date: Tue, 31 Mar 2015 15:27:48 +1100 Subject: [PATCH] Removes the extensibility files and build for identity stuff - that now exists in a separate github repo. --- build/Build.bat | 1 - build/Build.proj | 23 -- build/NuSpecs/UmbracoCms.Identity.nuspec | 24 -- build/NuSpecs/UmbracoExamine.PDF.nuspec | 23 -- src/Umbraco.Web.UI/App_Start/Readme.txt | 33 -- .../UmbracoBackOfficeAuthExtensions.cs | 308 ------------------ .../App_Start/UmbracoCustomOwinStartup.cs | 60 ---- .../App_Start/UmbracoStandardOwinStartup.cs | 50 --- src/Umbraco.Web.UI/Umbraco.Web.UI.csproj | 1 - src/umbraco.sln | 1 - 10 files changed, 524 deletions(-) delete mode 100644 build/NuSpecs/UmbracoCms.Identity.nuspec delete mode 100644 build/NuSpecs/UmbracoExamine.PDF.nuspec delete mode 100644 src/Umbraco.Web.UI/App_Start/Readme.txt delete mode 100644 src/Umbraco.Web.UI/App_Start/UmbracoBackOfficeAuthExtensions.cs delete mode 100644 src/Umbraco.Web.UI/App_Start/UmbracoCustomOwinStartup.cs delete mode 100644 src/Umbraco.Web.UI/App_Start/UmbracoStandardOwinStartup.cs diff --git a/build/Build.bat b/build/Build.bat index 7a464b422c..1b715dcc15 100644 --- a/build/Build.bat +++ b/build/Build.bat @@ -56,7 +56,6 @@ REN .\_BuildOutput\WebApp\Xslt\Web.config Web.config.transform ECHO Packing the NuGet release files ..\src\.nuget\NuGet.exe Pack NuSpecs\UmbracoCms.Core.nuspec -Version %version% ..\src\.nuget\NuGet.exe Pack NuSpecs\UmbracoCms.nuspec -Version %version% -..\src\.nuget\NuGet.exe Pack NuSpecs\UmbracoCms.Identity.nuspec IF ERRORLEVEL 1 GOTO :showerror diff --git a/build/Build.proj b/build/Build.proj index ab346f7438..264f71a5d5 100644 --- a/build/Build.proj +++ b/build/Build.proj @@ -88,7 +88,6 @@ $(BuildFolderAbsolutePath)WebApp\ $(BuildFolderRelativeToProjects)WebPi\ $(BuildFolderAbsolutePath)WebPi\ - $(BuildFolderAbsolutePath)IdentityTemplates\ @@ -158,28 +157,6 @@ - - - - - - - - - - - - - - - - - - diff --git a/build/NuSpecs/UmbracoCms.Identity.nuspec b/build/NuSpecs/UmbracoCms.Identity.nuspec deleted file mode 100644 index c635b891f7..0000000000 --- a/build/NuSpecs/UmbracoCms.Identity.nuspec +++ /dev/null @@ -1,24 +0,0 @@ - - - - UmbracoCms.Identity - 1.0.0 - Umbraco Extensibility for ASP.Net Identity - Umbraco HQ - Umbraco HQ - http://opensource.org/licenses/MIT - http://umbraco.com/ - http://umbraco.com/media/357769/100px_transparent.png - false - Installs files/classes to help with ASP.Net Identity extensibility for Umbraco back office - Installs classes to help with ASP.Net Identity extensibility for Umbraco - en-US - umbraco aspnet identity - - - - - - - - \ No newline at end of file diff --git a/build/NuSpecs/UmbracoExamine.PDF.nuspec b/build/NuSpecs/UmbracoExamine.PDF.nuspec deleted file mode 100644 index 5d1afff2b5..0000000000 --- a/build/NuSpecs/UmbracoExamine.PDF.nuspec +++ /dev/null @@ -1,23 +0,0 @@ - - - - UmbracoExamine.PDF - 0.7.0 - Umbraco HQ - Umbraco HQ - http://opensource.org/licenses/MIT - http://umbraco.com/ - http://umbraco.com/media/357769/100px_transparent.png - false - UmbracoExmine.PDF - umbraco - - - - - - - - - - \ No newline at end of file diff --git a/src/Umbraco.Web.UI/App_Start/Readme.txt b/src/Umbraco.Web.UI/App_Start/Readme.txt deleted file mode 100644 index b8897a27ea..0000000000 --- a/src/Umbraco.Web.UI/App_Start/Readme.txt +++ /dev/null @@ -1,33 +0,0 @@ - - _ _ __ __ ____ _____ _____ ____ - | | | | \/ | _ \| __ \ /\ / ____/ __ \ - | | | | \ / | |_) | |__) | / \ | | | | | | - | | | | |\/| | _ <| _ / / /\ \| | | | | | - | |__| | | | | |_) | | \ \ / ____ | |___| |__| | - \____/|_| |_|____/|_| \_/_/ \_\_____\____/ - ----------------------------------------------------- - -Umbraco extensibility code has been installed for ASP.Net Identity with Umbraco back office users - -The files have been installed into your App_Start folder if you have a Web Application project -or into App_Code if you have a Website project. - -All of these files include lots of code comments, documentation & notes to assist with extending -the ASP.Net Identity implementaion for back office users in Umbraco. For all 3rd party -ASP.Net providers, their dependencies will need to be manually installed. See comments in the -following files for full details: - -* StandardUmbracoOwinStartup.cs Includes code snippets to enable 3rd party ASP.Net Identity - providers to work with the Umbraco back office. - To enable the 'StandardUmbracoOwinStartup', update the web.config - appSetting "owin:appStartup" to be: "StandardUmbracoOwinStartup" - -* UmbracoCustomOwinStartup Includes code snippets to customize the Umbraco ASP.Net - Identity implementation for back office users as well as - snippets to enable 3rd party ASP.Net Identity providers to work. - To enable the 'UmbracoCustomOwinStartup', update the web.config - appSetting "owin:appStartup" to be: "UmbracoCustomOwinStartup" - -* UmbracoBackOfficeAuthExtensions Includes extension methods snippets to enable 3rd party ASP.Net - Identity providers to work with the Umbraco back office. \ No newline at end of file diff --git a/src/Umbraco.Web.UI/App_Start/UmbracoBackOfficeAuthExtensions.cs b/src/Umbraco.Web.UI/App_Start/UmbracoBackOfficeAuthExtensions.cs deleted file mode 100644 index 66ecfb1373..0000000000 --- a/src/Umbraco.Web.UI/App_Start/UmbracoBackOfficeAuthExtensions.cs +++ /dev/null @@ -1,308 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Linq; -using System.Security.Claims; -using System.Threading.Tasks; -using System.Web; -using Microsoft.Owin; -using Owin; -using Umbraco.Core; -using Umbraco.Web.Security.Identity; -//using Microsoft.Owin.Security.Facebook; -//using Microsoft.Owin.Security.Google; -//using Microsoft.Owin.Security.OpenIdConnect; -//using Microsoft.Owin.Security.MicrosoftAccount; -//using Microsoft.IdentityModel.Clients.ActiveDirectory; - -namespace Umbraco.Web.UI -{ - public static class UmbracoBackOfficeAuthExtensions - { - /* - - /// - /// Configure microsoft account sign-in - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// Nuget installation: - /// Microsoft.Owin.Security.MicrosoftAccount - /// - /// Microsoft account documentation for ASP.Net Identity can be found: - /// - /// http://www.asp.net/web-api/overview/security/external-authentication-services#MICROSOFT - /// http://blogs.msdn.com/b/webdev/archive/2012/09/19/configuring-your-asp-net-application-for-microsoft-oauth-account.aspx - /// - /// Microsoft apps can be created here: - /// - /// http://go.microsoft.com/fwlink/?LinkID=144070 - /// - /// - public static void ConfigureBackOfficeMicrosoftAuth(this IAppBuilder app, string clientId, string clientSecret, - string caption = "Microsoft", string style = "btn-microsoft", string icon = "fa-windows") - { - var msOptions = new MicrosoftAccountAuthenticationOptions - { - ClientId = clientId, - ClientSecret = clientSecret, - SignInAsAuthenticationType = Constants.Security.BackOfficeExternalAuthenticationType - }; - msOptions.ForUmbracoBackOffice(style, icon); - msOptions.Caption = caption; - app.UseMicrosoftAccountAuthentication(msOptions); - } - - /// - /// Configure google sign-in - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// Nuget installation: - /// Microsoft.Owin.Security.Google - /// - /// Google account documentation for ASP.Net Identity can be found: - /// - /// http://www.asp.net/web-api/overview/security/external-authentication-services#GOOGLE - /// - /// Google apps can be created here: - /// - /// https://developers.google.com/accounts/docs/OpenIDConnect#getcredentials - /// - /// - public static void ConfigureBackOfficeGoogleAuth(this IAppBuilder app, string clientId, string clientSecret, - string caption = "Google", string style = "btn-google-plus", string icon = "fa-google-plus") - { - var googleOptions = new GoogleOAuth2AuthenticationOptions - { - ClientId = clientId, - ClientSecret = clientSecret, - //In order to allow using different google providers on the front-end vs the back office, - // these settings are very important to make them distinguished from one another. - SignInAsAuthenticationType = Constants.Security.BackOfficeExternalAuthenticationType, - // By default this is '/signin-google', you will need to change that default value in your - // Google developer settings for your web-app in the "REDIRECT URIS" setting - CallbackPath = new PathString("/umbraco-google-signin") - }; - googleOptions.ForUmbracoBackOffice(style, icon); - googleOptions.Caption = caption; - app.UseGoogleAuthentication(googleOptions); - } - - /// - /// Configure facebook sign-in - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// Nuget installation: - /// Microsoft.Owin.Security.Facebook - /// - /// Facebook account documentation for ASP.Net Identity can be found: - /// - /// http://www.asp.net/web-api/overview/security/external-authentication-services#FACEBOOK - /// - /// Facebook apps can be created here: - /// - /// https://developers.facebook.com/ - /// - /// - public static void ConfigureBackOfficeFacebookAuth(this IAppBuilder app, string appId, string appSecret, - string caption = "Facebook", string style = "btn-facebook", string icon = "fa-facebook") - { - var fbOptions = new FacebookAuthenticationOptions - { - AppId = appId, - AppSecret = appSecret, - //In order to allow using different google providers on the front-end vs the back office, - // these settings are very important to make them distinguished from one another. - SignInAsAuthenticationType = Constants.Security.BackOfficeExternalAuthenticationType, - // By default this is '/signin-facebook', you will need to change that default value in your - // Facebook developer settings for your app in the Advanced settings under "Client OAuth Login" - // in the "Valid OAuth redirect URIs", specify the full URL, for example: http://mysite.com/umbraco-facebook-signin - CallbackPath = new PathString("/umbraco-facebook-signin") - }; - fbOptions.ForUmbracoBackOffice(style, icon); - fbOptions.Caption = caption; - app.UseFacebookAuthentication(fbOptions); - } - - /// - /// Configure ActiveDirectory sign-in - /// - /// - /// - /// - /// - /// The URL that will be redirected to after login is successful, example: http://mydomain.com/umbraco/; - /// - /// - /// - /// This by default is 'OpenIdConnect' but that doesn't match what ASP.Net Identity actually stores in the - /// loginProvider field in the database which looks something like this (for example): - /// https://sts.windows.net/3bb0b4c5-364f-4394-ad36-0f29f95e5ggg/ - /// and is based on your AD setup. This value needs to match in order for accounts to - /// detected as linked/un-linked in the back office. - /// - /// - /// - /// - /// - /// - /// Nuget installation: - /// Install-Package Microsoft.Owin.Security.OpenIdConnect - /// Install-Package Microsoft.IdentityModel.Clients.ActiveDirectory - /// - /// ActiveDirectory account documentation for ASP.Net Identity can be found: - /// - /// https://github.com/AzureADSamples/WebApp-WebAPI-OpenIDConnect-DotNet - /// - /// This configuration requires the NaiveSessionCache class below which will need to be un-commented - /// - /// - public static void ConfigureBackOfficeActiveDirectoryAuth(this IAppBuilder app, - string tenant, string clientId, string postLoginRedirectUri, string appKey, - string authType, - string caption = "Active Directory", string style = "btn-microsoft", string icon = "fa-windows") - { - const string aadInstance = "https://login.windows.net/{0}"; - const string graphResourceId = "https://graph.windows.net"; - - var authority = string.Format(CultureInfo.InvariantCulture, aadInstance, tenant); - var adOptions = new OpenIdConnectAuthenticationOptions - { - AuthenticationType = authType, - SignInAsAuthenticationType = Constants.Security.BackOfficeExternalAuthenticationType, - ClientId = clientId, - Authority = authority, - PostLogoutRedirectUri = postLoginRedirectUri, - Notifications = new OpenIdConnectAuthenticationNotifications() - { - // If there is a code in the OpenID Connect response, redeem it for an access token and refresh token, and store those away. - AuthorizationCodeReceived = (context) => - { - var credential = new ClientCredential(clientId, appKey); - var userObjectId = context.AuthenticationTicket.Identity.FindFirst("http://schemas.microsoft.com/identity/claims/objectidentifier").Value; - var authContext = new AuthenticationContext(authority, new NaiveSessionCache(userObjectId)); - var result = authContext.AcquireTokenByAuthorizationCode( - context.Code, - //NOTE: This URL needs to match EXACTLY the same path that is configured in the AD configuration. - new Uri( - HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + - HttpContext.Current.Request.RawUrl.EnsureStartsWith('/').EnsureEndsWith('/')), - credential, - graphResourceId); - - return Task.FromResult(0); - } - - } - - }; - adOptions.ForUmbracoBackOffice(style, icon); - adOptions.Caption = caption; - app.UseOpenIdConnectAuthentication(adOptions); - } - - */ - - } - - - - /* - - /// - /// A Session cache token storage which is required to initialize the AD Identity provider on startup - /// - /// - /// Based on the examples from the AD samples: - /// https://github.com/AzureADSamples/WebApp-WebAPI-OpenIDConnect-DotNet/blob/master/TodoListWebApp/Utils/NaiveSessionCache.cs - /// - /// There are some newer examples of different token storage including persistent storage here: - /// It would appear that this is better for whatever reason: https://github.com/OfficeDev/O365-WebApp-SingleTenant/blob/master/O365-WebApp-SingleTenant/Models/ADALTokenCache.cs - /// - /// The type of token storage will be dependent on your requirements but this should be fine for standard installations - /// - public class NaiveSessionCache : TokenCache - { - private static readonly object FileLock = new object(); - readonly string _cacheId; - public NaiveSessionCache(string userId) - { - _cacheId = userId + "_TokenCache"; - - AfterAccess = AfterAccessNotification; - BeforeAccess = BeforeAccessNotification; - Load(); - } - - public void Load() - { - lock (FileLock) - { - Deserialize((byte[])HttpContext.Current.Session[_cacheId]); - } - } - - public void Persist() - { - lock (FileLock) - { - // reflect changes in the persistent store - HttpContext.Current.Session[_cacheId] = Serialize(); - // once the write operation took place, restore the HasStateChanged bit to false - HasStateChanged = false; - } - } - - // Empties the persistent store. - public override void Clear() - { - base.Clear(); - HttpContext.Current.Session.Remove(_cacheId); - } - - public override void DeleteItem(TokenCacheItem item) - { - base.DeleteItem(item); - Persist(); - } - - // Triggered right before ADAL needs to access the cache. - // Reload the cache from the persistent store in case it changed since the last access. - void BeforeAccessNotification(TokenCacheNotificationArgs args) - { - Load(); - } - - // Triggered right after ADAL accessed the cache. - void AfterAccessNotification(TokenCacheNotificationArgs args) - { - // if the access operation resulted in a cache update - if (HasStateChanged) - { - Persist(); - } - } - } - - */ -} \ No newline at end of file diff --git a/src/Umbraco.Web.UI/App_Start/UmbracoCustomOwinStartup.cs b/src/Umbraco.Web.UI/App_Start/UmbracoCustomOwinStartup.cs deleted file mode 100644 index a50e50fa1e..0000000000 --- a/src/Umbraco.Web.UI/App_Start/UmbracoCustomOwinStartup.cs +++ /dev/null @@ -1,60 +0,0 @@ -using Microsoft.Owin; -using Owin; -using Umbraco.Core; -using Umbraco.Core.Security; -using Umbraco.Web.Security.Identity; -using Umbraco.Web.UI; - -[assembly: OwinStartup("CustomUmbracoOwinStartup", typeof(StandardUmbracoOwinStartup))] - -namespace Umbraco.Web.UI -{ - /// - /// A custom way to configure OWIN for Umbraco - /// - /// - /// 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) - { - //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 - app - .UseUmbracoBackOfficeCookieAuthentication() - .UseUmbracoBackOfficeExternalCookieAuthentication(); - - /* - * 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/App_Start/UmbracoStandardOwinStartup.cs b/src/Umbraco.Web.UI/App_Start/UmbracoStandardOwinStartup.cs deleted file mode 100644 index 0c7a06d0f5..0000000000 --- a/src/Umbraco.Web.UI/App_Start/UmbracoStandardOwinStartup.cs +++ /dev/null @@ -1,50 +0,0 @@ -using Microsoft.Owin; -using Owin; -using Umbraco.Core; -using Umbraco.Core.Security; -using Umbraco.Web.Security.Identity; -using Umbraco.Web.UI; - -[assembly: OwinStartup("StandardUmbracoOwinStartup", 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 8d2c185043..095cf28afc 100644 --- a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj +++ b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj @@ -2554,7 +2554,6 @@ - diff --git a/src/umbraco.sln b/src/umbraco.sln index 71c8e27411..d839dd0a01 100644 --- a/src/umbraco.sln +++ b/src/umbraco.sln @@ -31,7 +31,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NuSpecs", "NuSpecs", "{227C ..\build\NuSpecs\UmbracoCms.Core.AllBinaries.nuspec = ..\build\NuSpecs\UmbracoCms.Core.AllBinaries.nuspec ..\build\NuSpecs\UmbracoCms.Core.nuspec = ..\build\NuSpecs\UmbracoCms.Core.nuspec ..\build\NuSpecs\UmbracoCms.Core.Symbols.nuspec = ..\build\NuSpecs\UmbracoCms.Core.Symbols.nuspec - ..\build\NuSpecs\UmbracoCms.Identity.nuspec = ..\build\NuSpecs\UmbracoCms.Identity.nuspec ..\build\NuSpecs\UmbracoCms.nuspec = ..\build\NuSpecs\UmbracoCms.nuspec EndProjectSection EndProject