From cd2f512284dedba1e6ac8118c091fce40ab82d09 Mon Sep 17 00:00:00 2001 From: Shannon Date: Mon, 4 May 2015 11:02:23 +1000 Subject: [PATCH] moves auth server classes to the identity extensions sln --- .../Identity/BackOfficeAuthServerProvider.cs | 47 ------------------- .../BackOfficeAuthServerProviderOptions.cs | 15 ------ src/Umbraco.Web/Umbraco.Web.csproj | 2 - 3 files changed, 64 deletions(-) delete mode 100644 src/Umbraco.Web/Security/Identity/BackOfficeAuthServerProvider.cs delete mode 100644 src/Umbraco.Web/Security/Identity/BackOfficeAuthServerProviderOptions.cs diff --git a/src/Umbraco.Web/Security/Identity/BackOfficeAuthServerProvider.cs b/src/Umbraco.Web/Security/Identity/BackOfficeAuthServerProvider.cs deleted file mode 100644 index d3e33a14ad..0000000000 --- a/src/Umbraco.Web/Security/Identity/BackOfficeAuthServerProvider.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System; -using System.Threading.Tasks; -using Microsoft.AspNet.Identity; -using Microsoft.AspNet.Identity.Owin; -using Microsoft.Owin.Security.OAuth; -using Umbraco.Core.Security; - -namespace Umbraco.Web.Security.Identity -{ - /// - /// A simple OAuth server provider to verify back office users - /// - public class BackOfficeAuthServerProvider : OAuthAuthorizationServerProvider - { - private readonly BackOfficeAuthServerProviderOptions _options; - - public BackOfficeAuthServerProvider(BackOfficeAuthServerProviderOptions options = null) - { - if (options == null) - options = new BackOfficeAuthServerProviderOptions(); - _options = options; - } - - public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context) - { - var userManager = context.OwinContext.GetUserManager(); - - if (_options.AllowCors) - { - context.OwinContext.Response.Headers.Add("Access-Control-Allow-Origin", new[] { "*" }); - } - - - var user = await userManager.FindAsync(context.UserName, context.Password); - - if (user == null) - { - context.SetError("invalid_grant", "The user name or password is incorrect."); - return; - } - - var identity = await userManager.ClaimsIdentityFactory.CreateAsync(userManager, user, context.Options.AuthenticationType); - - context.Validated(identity); - } - } -} \ No newline at end of file diff --git a/src/Umbraco.Web/Security/Identity/BackOfficeAuthServerProviderOptions.cs b/src/Umbraco.Web/Security/Identity/BackOfficeAuthServerProviderOptions.cs deleted file mode 100644 index 61bd7b088c..0000000000 --- a/src/Umbraco.Web/Security/Identity/BackOfficeAuthServerProviderOptions.cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace Umbraco.Web.Security.Identity -{ - public sealed class BackOfficeAuthServerProviderOptions - { - public BackOfficeAuthServerProviderOptions() - { - AllowCors = false; - } - - /// - /// True or false to allow CORS (Cross origin resource sharing) - /// - public bool AllowCors { get; set; } - } -} \ No newline at end of file diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index 2e10badd89..71964cf16f 100644 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -304,8 +304,6 @@ - -