Permalink
Browse files

Initial Identity Core port, with Crypto/Claims #if net45 commented out

  • Loading branch information...
HaoK committed Feb 19, 2014
1 parent 79d615f commit aa4787cc67ed02ba0d2c08adecf8ada75b2d7239
Showing with 3,304 additions and 4 deletions.
  1. +4 −4 Identity.sln
  2. +29 −0 src/Microsoft.AspNet.Identity/IClaimsIdentityFactory.cs
  3. +38 −0 src/Microsoft.AspNet.Identity/IIdentityMessageService.cs
  4. +18 −0 src/Microsoft.AspNet.Identity/IIdentityValidator.cs
  5. +23 −0 src/Microsoft.AspNet.Identity/IPasswordHasher.cs
  6. +25 −0 src/Microsoft.AspNet.Identity/IQueryableRoleStore.cs
  7. +25 −0 src/Microsoft.AspNet.Identity/IQueryableUserStore.cs
  8. +19 −0 src/Microsoft.AspNet.Identity/IRole.cs
  9. +48 −0 src/Microsoft.AspNet.Identity/IRoleStore.cs
  10. +19 −0 src/Microsoft.AspNet.Identity/IUser.cs
  11. +41 −0 src/Microsoft.AspNet.Identity/IUserClaimStore.cs
  12. +49 −0 src/Microsoft.AspNet.Identity/IUserEmailStore.cs
  13. +66 −0 src/Microsoft.AspNet.Identity/IUserLockoutStore.cs
  14. +42 −0 src/Microsoft.AspNet.Identity/IUserLoginStore.cs
  15. +34 −0 src/Microsoft.AspNet.Identity/IUserPasswordStore.cs
  16. +42 −0 src/Microsoft.AspNet.Identity/IUserPhoneNumberStore.cs
  17. +44 −0 src/Microsoft.AspNet.Identity/IUserRoleStore.cs
  18. +27 −0 src/Microsoft.AspNet.Identity/IUserSecurityStampStore.cs
  19. +48 −0 src/Microsoft.AspNet.Identity/IUserStore.cs
  20. +47 −0 src/Microsoft.AspNet.Identity/IUserTokenProvider.cs
  21. +27 −0 src/Microsoft.AspNet.Identity/IUserTwoFactorStore.cs
  22. +69 −0 src/Microsoft.AspNet.Identity/IdentityResult.cs
  23. +23 −0 src/Microsoft.AspNet.Identity/PasswordVerificationResult.cs
  24. +382 −0 src/Microsoft.AspNet.Identity/Resources.Designer.cs
  25. +260 −0 src/Microsoft.AspNet.Identity/Resources.resx
  26. +115 −0 src/Microsoft.AspNet.Identity/Rfc6238AuthenticationService.cs
  27. +29 −0 src/Microsoft.AspNet.Identity/UserLoginInfo.cs
  28. +1,711 −0 src/Microsoft.AspNet.Identity/UserManager.cs
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.21126.0
VisualStudioVersion = 12.0.21005.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{0F647068-6602-4E24-B1DC-8ED91481A50A}"
EndProject
@@ -46,11 +46,11 @@ Global
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{77CEDA6C-A833-455D-8357-649BFD944724} = {0F647068-6602-4E24-B1DC-8ED91481A50A}
{F6B0C0E9-C346-49D0-B583-95B6CE04BB1B} = {0F647068-6602-4E24-B1DC-8ED91481A50A}
{6211450F-FFB8-431F-84E2-9A7620875260} = {77CEDA6C-A833-455D-8357-649BFD944724}
{D32483A4-B617-480C-81E6-49CD596B9A34} = {77CEDA6C-A833-455D-8357-649BFD944724}
{77CEDA6C-A833-455D-8357-649BFD944724} = {0F647068-6602-4E24-B1DC-8ED91481A50A}
{B72401D7-47F6-4A98-89D5-CCBFEFC5B2B8} = {F6B0C0E9-C346-49D0-B583-95B6CE04BB1B}
{E52361C9-1F0B-4229-86A0-E5C7C12A5429} = {F6B0C0E9-C346-49D0-B583-95B6CE04BB1B}
{6211450F-FFB8-431F-84E2-9A7620875260} = {77CEDA6C-A833-455D-8357-649BFD944724}
{D32483A4-B617-480C-81E6-49CD596B9A34} = {77CEDA6C-A833-455D-8357-649BFD944724}
EndGlobalSection
EndGlobal
@@ -0,0 +1,29 @@
using System;
#if NET45
using System.Security.Claims;
#endif
using System.Threading.Tasks;
namespace Microsoft.AspNet.Identity
{
/// <summary>
/// Interface for creating a ClaimsIdentity from an IUser
/// </summary>
/// <typeparam name="TUser"></typeparam>
/// <typeparam name="TKey"></typeparam>
public interface IClaimsIdentityFactory<TUser, TKey>
where TUser : class, IUser<TKey>
where TKey : IEquatable<TKey>
{
#if NET45
/// <summary>
/// Create a ClaimsIdentity from an user using a UserManager
/// </summary>
/// <param name="manager"></param>
/// <param name="user"></param>
/// <param name="authenticationType"></param>
/// <returns></returns>
Task<ClaimsIdentity> Create(UserManager<TUser, TKey> manager, TUser user, string authenticationType);
#endif
}
}
@@ -0,0 +1,38 @@
using System.Threading.Tasks;
namespace Microsoft.AspNet.Identity
{
/// <summary>
/// Expose a way to send messages (email/txt)
/// </summary>
public interface IIdentityMessageService
{
/// <summary>
/// This method should send the message
/// </summary>
/// <param name="message"></param>
/// <returns></returns>
Task Send(IdentityMessage message);
}
/// <summary>
/// Represents a message
/// </summary>
public class IdentityMessage
{
/// <summary>
/// Destination, i.e. To email, or SMS phone number
/// </summary>
public virtual string Destination { get; set; }
/// <summary>
/// Subject
/// </summary>
public virtual string Subject { get; set; }
/// <summary>
/// Message contents
/// </summary>
public virtual string Body { get; set; }
}
}
@@ -0,0 +1,18 @@
using System.Threading.Tasks;
namespace Microsoft.AspNet.Identity
{
/// <summary>
/// Used to validate an item
/// </summary>
/// <typeparam name="T"></typeparam>
public interface IIdentityValidator<in T>
{
/// <summary>
/// Validate the item
/// </summary>
/// <param name="item"></param>
/// <returns></returns>
Task<IdentityResult> Validate(T item);
}
}
@@ -0,0 +1,23 @@
namespace Microsoft.AspNet.Identity
{
/// <summary>
/// Abstraction for password hashing methods
/// </summary>
public interface IPasswordHasher
{
/// <summary>
/// Hash a password
/// </summary>
/// <param name="password"></param>
/// <returns></returns>
string HashPassword(string password);
/// <summary>
/// Verify that a password matches the hashed password
/// </summary>
/// <param name="hashedPassword"></param>
/// <param name="providedPassword"></param>
/// <returns></returns>
PasswordVerificationResult VerifyHashedPassword(string hashedPassword, string providedPassword);
}
}
@@ -0,0 +1,25 @@
using System.Linq;
namespace Microsoft.AspNet.Identity
{
/// <summary>
/// Interface that exposes an IQueryable roles
/// </summary>
/// <typeparam name="TRole"></typeparam>
public interface IQueryableRoleStore<TRole> : IQueryableRoleStore<TRole, string> where TRole : IRole<string>
{
}
/// <summary>
/// Interface that exposes an IQueryable roles
/// </summary>
/// <typeparam name="TRole"></typeparam>
/// <typeparam name="TKey"></typeparam>
public interface IQueryableRoleStore<TRole, in TKey> : IRoleStore<TRole, TKey> where TRole : IRole<TKey>
{
/// <summary>
/// IQueryable users
/// </summary>
IQueryable<TRole> Roles { get; }
}
}
@@ -0,0 +1,25 @@
using System.Linq;
namespace Microsoft.AspNet.Identity
{
/// <summary>
/// Interface that exposes an IQueryable users
/// </summary>
/// <typeparam name="TUser"></typeparam>
public interface IQueryableUserStore<TUser> : IQueryableUserStore<TUser, string> where TUser : class, IUser<string>
{
}
/// <summary>
/// Interface that exposes an IQueryable users
/// </summary>
/// <typeparam name="TUser"></typeparam>
/// <typeparam name="TKey"></typeparam>
public interface IQueryableUserStore<TUser, in TKey> : IUserStore<TUser, TKey> where TUser : class, IUser<TKey>
{
/// <summary>
/// IQueryable users
/// </summary>
IQueryable<TUser> Users { get; }
}
}
@@ -0,0 +1,19 @@
namespace Microsoft.AspNet.Identity
{
/// <summary>
/// Mimimal set of data needed to persist role data
/// </summary>
/// <typeparam name="TKey"></typeparam>
public interface IRole<out TKey>
{
/// <summary>
/// Id of the role
/// </summary>
TKey Id { get; }
/// <summary>
/// Name of the role
/// </summary>
string Name { get; set; }
}
}
@@ -0,0 +1,48 @@
using System;
using System.Threading.Tasks;
namespace Microsoft.AspNet.Identity
{
/// <summary>
/// Interface that exposes basic role management
/// </summary>
/// <typeparam name="TRole"></typeparam>
/// <typeparam name="TKey"></typeparam>
public interface IRoleStore<TRole, in TKey> : IDisposable where TRole : IRole<TKey>
{
/// <summary>
/// Insert a new role
/// </summary>
/// <param name="role"></param>
/// <returns></returns>
Task Create(TRole role);
/// <summary>
/// Update a role
/// </summary>
/// <param name="role"></param>
/// <returns></returns>
Task Update(TRole role);
/// <summary>
/// Delete a role
/// </summary>
/// <param name="role"></param>
/// <returns></returns>
Task Delete(TRole role);
/// <summary>
/// Finds a role by id
/// </summary>
/// <param name="roleId"></param>
/// <returns></returns>
Task<TRole> FindById(TKey roleId);
/// <summary>
/// Find a role by name
/// </summary>
/// <param name="roleName"></param>
/// <returns></returns>
Task<TRole> FindByName(string roleName);
}
}
@@ -0,0 +1,19 @@
namespace Microsoft.AspNet.Identity
{
/// <summary>
/// Minimal interface for a user with id and username
/// </summary>
/// <typeparam name="TKey"></typeparam>
public interface IUser<out TKey>
{
/// <summary>
/// Unique key for the user
/// </summary>
TKey Id { get; }
/// <summary>
/// Unique username
/// </summary>
string UserName { get; set; }
}
}
@@ -0,0 +1,41 @@
#if NET45
using System.Collections.Generic;
using System.Security.Claims;
using System.Threading.Tasks;
namespace Microsoft.AspNet.Identity
{
/// <summary>
/// Stores user specific claims
/// </summary>
/// <typeparam name="TUser"></typeparam>
/// <typeparam name="TKey"></typeparam>
public interface IUserClaimStore<TUser, in TKey> : IUserStore<TUser, TKey> where TUser : class, IUser<TKey>
{
/// <summary>
/// Returns the claims for the user with the issuer set
/// </summary>
/// <param name="user"></param>
/// <returns></returns>
Task<IList<Claim>> GetClaims(TUser user);
/// <summary>
/// Add a new user claim
/// </summary>
/// <param name="user"></param>
/// <param name="claim"></param>
/// <returns></returns>
Task AddClaim(TUser user, Claim claim);
/// <summary>
/// Remove a user claim
/// </summary>
/// <param name="user"></param>
/// <param name="claim"></param>
/// <returns></returns>
Task RemoveClaim(TUser user, Claim claim);
}
}
#endif
@@ -0,0 +1,49 @@
using System.Threading.Tasks;
namespace Microsoft.AspNet.Identity
{
/// <summary>
/// Stores a user's email
/// </summary>
/// <typeparam name="TUser"></typeparam>
/// <typeparam name="TKey"></typeparam>
public interface IUserEmailStore<TUser, in TKey> : IUserStore<TUser, TKey> where TUser : class, IUser<TKey>
{
/// <summary>
/// Set the user email
/// </summary>
/// <param name="user"></param>
/// <param name="email"></param>
/// <returns></returns>
Task SetEmail(TUser user, string email);
/// <summary>
/// Get the user email
/// </summary>
/// <param name="user"></param>
/// <returns></returns>
Task<string> GetEmail(TUser user);
/// <summary>
/// Returns true if the user email is confirmed
/// </summary>
/// <param name="user"></param>
/// <returns></returns>
Task<bool> GetEmailConfirmed(TUser user);
/// <summary>
/// Sets whether the user email is confirmed
/// </summary>
/// <param name="user"></param>
/// <param name="confirmed"></param>
/// <returns></returns>
Task SetEmailConfirmed(TUser user, bool confirmed);
/// <summary>
/// Returns the user associated with this email
/// </summary>
/// <param name="email"></param>
/// <returns></returns>
Task<TUser> FindByEmail(string email);
}
}
Oops, something went wrong.

0 comments on commit aa4787c

Please sign in to comment.