diff --git a/src/Microsoft.AspNet.Identity/IClaimsIdentityFactory.cs b/src/Microsoft.AspNet.Identity/IClaimsIdentityFactory.cs index bd5562df13..1a4518016c 100644 --- a/src/Microsoft.AspNet.Identity/IClaimsIdentityFactory.cs +++ b/src/Microsoft.AspNet.Identity/IClaimsIdentityFactory.cs @@ -1,6 +1,8 @@ using System; #if NET45 using System.Security.Claims; +#else +using System.Security.ClaimsK; #endif using System.Threading.Tasks; @@ -15,7 +17,6 @@ namespace Microsoft.AspNet.Identity where TUser : class, IUser where TKey : IEquatable { -#if NET45 /// /// Create a ClaimsIdentity from an user using a UserManager /// @@ -24,6 +25,5 @@ namespace Microsoft.AspNet.Identity /// /// Task Create(UserManager manager, TUser user, string authenticationType); -#endif } } \ No newline at end of file diff --git a/src/Microsoft.AspNet.Identity/IUserClaimStore.cs b/src/Microsoft.AspNet.Identity/IUserClaimStore.cs index b1bffbbc59..043aa00274 100644 --- a/src/Microsoft.AspNet.Identity/IUserClaimStore.cs +++ b/src/Microsoft.AspNet.Identity/IUserClaimStore.cs @@ -1,7 +1,9 @@ -#if NET45 - -using System.Collections.Generic; +using System.Collections.Generic; +#if NET45 using System.Security.Claims; +#else +using System.Security.ClaimsK; +#endif using System.Threading.Tasks; namespace Microsoft.AspNet.Identity @@ -36,6 +38,4 @@ namespace Microsoft.AspNet.Identity /// Task RemoveClaim(TUser user, Claim claim); } -} - -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.Identity/UserManager.cs b/src/Microsoft.AspNet.Identity/UserManager.cs index 6238936636..bbd96f3411 100644 --- a/src/Microsoft.AspNet.Identity/UserManager.cs +++ b/src/Microsoft.AspNet.Identity/UserManager.cs @@ -2,8 +2,11 @@ using System; using System.Collections.Generic; using System.Globalization; using System.Linq; +using Microsoft.AspNet.DependencyInjection; #if NET45 using System.Security.Claims; +#else +using System.Security.ClaimsK; #endif using System.Text; using System.Threading.Tasks; @@ -29,6 +32,22 @@ namespace Microsoft.AspNet.Identity private IIdentityValidator _passwordValidator; private IIdentityValidator _userValidator; + /// + /// Constructor which takes a service provider to find the default interfaces to hook up + /// + /// + public UserManager(IServiceProvider serviceProvider) + { + if (serviceProvider == null) + { + throw new ArgumentNullException("serviceProvider"); + } + Store = serviceProvider.GetService>(); + ClaimsIdentityFactory = serviceProvider.GetService>(); + PasswordHasher = serviceProvider.GetService(); + // TODO: validator interfaces, and maybe each optional store as well? Email and SMS services? + } + /// /// Constructor /// @@ -324,7 +343,6 @@ namespace Microsoft.AspNet.Identity GC.SuppressFinalize(this); } -#if NET45 /// /// Creates a ClaimsIdentity representing the user /// @@ -340,7 +358,6 @@ namespace Microsoft.AspNet.Identity } return ClaimsIdentityFactory.Create(this, user, authenticationType); } -#endif /// /// Create a user with no password @@ -816,7 +833,6 @@ namespace Microsoft.AspNet.Identity return await loginStore.GetLogins(user).ConfigureAwait(false); } -#if NET45 // IUserClaimStore methods private IUserClaimStore GetClaimStore() { @@ -889,7 +905,6 @@ namespace Microsoft.AspNet.Identity } return await claimStore.GetClaims(user).ConfigureAwait(false); } -#endif private IUserRoleStore GetUserRoleStore() { diff --git a/src/Microsoft.AspNet.Identity/project.json b/src/Microsoft.AspNet.Identity/project.json index b32c888856..1c1f0c09df 100644 --- a/src/Microsoft.AspNet.Identity/project.json +++ b/src/Microsoft.AspNet.Identity/project.json @@ -1,7 +1,8 @@ { "version" : "0.1-alpha-*", "dependencies": { - "Microsoft.AspNet.DependencyInjection" : "0.1-alpha-*" + "Microsoft.AspNet.DependencyInjection" : "0.1-alpha-*", + "System.Security.Claims" : "0.1-alpha-*" }, "configurations": { "net45": {},