Add generic parm for IdentityRoleClaim
This commit is contained in:
parent
27f021ab93
commit
1a0cd3c4d1
|
|
@ -69,10 +69,10 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore
|
||||||
/// <typeparam name="TContext">The type of the data context class used to access the store.</typeparam>
|
/// <typeparam name="TContext">The type of the data context class used to access the store.</typeparam>
|
||||||
/// <typeparam name="TKey">The type of the primary key for a role.</typeparam>
|
/// <typeparam name="TKey">The type of the primary key for a role.</typeparam>
|
||||||
public class UserStore<TUser, TRole, TContext, TKey> : UserStore<TUser, TRole, TContext, TKey, IdentityUserClaim<TKey>, IdentityUserRole<TKey>, IdentityUserLogin<TKey>, IdentityUserToken<TKey>>
|
public class UserStore<TUser, TRole, TContext, TKey> : UserStore<TUser, TRole, TContext, TKey, IdentityUserClaim<TKey>, IdentityUserRole<TKey>, IdentityUserLogin<TKey>, IdentityUserToken<TKey>>
|
||||||
where TUser : IdentityUser<TKey>
|
where TUser : IdentityUser<TKey>
|
||||||
where TRole : IdentityRole<TKey>
|
where TRole : IdentityRole<TKey>
|
||||||
where TContext : DbContext
|
where TContext : DbContext
|
||||||
where TKey : IEquatable<TKey>
|
where TKey : IEquatable<TKey>
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructs a new instance of <see cref="UserStore{TUser, TRole, TContext, TKey}"/>.
|
/// Constructs a new instance of <see cref="UserStore{TUser, TRole, TContext, TKey}"/>.
|
||||||
|
|
@ -158,6 +158,38 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore
|
||||||
/// <typeparam name="TUserLogin">The type representing a user external login.</typeparam>
|
/// <typeparam name="TUserLogin">The type representing a user external login.</typeparam>
|
||||||
/// <typeparam name="TUserToken">The type representing a user token.</typeparam>
|
/// <typeparam name="TUserToken">The type representing a user token.</typeparam>
|
||||||
public abstract class UserStore<TUser, TRole, TContext, TKey, TUserClaim, TUserRole, TUserLogin, TUserToken> :
|
public abstract class UserStore<TUser, TRole, TContext, TKey, TUserClaim, TUserRole, TUserLogin, TUserToken> :
|
||||||
|
UserStore<TUser, TRole, TContext, TKey,TUserClaim, TUserRole, TUserLogin, TUserToken, IdentityRoleClaim<TKey>>
|
||||||
|
where TUser : IdentityUser<TKey, TUserClaim, TUserRole, TUserLogin>
|
||||||
|
where TRole : IdentityRole<TKey, TUserRole, IdentityRoleClaim<TKey>>
|
||||||
|
where TContext : DbContext
|
||||||
|
where TKey : IEquatable<TKey>
|
||||||
|
where TUserClaim : IdentityUserClaim<TKey>
|
||||||
|
where TUserRole : IdentityUserRole<TKey>
|
||||||
|
where TUserLogin : IdentityUserLogin<TKey>
|
||||||
|
where TUserToken : IdentityUserToken<TKey>
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new instance of <see cref="UserStore"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="context">The context used to access the store.</param>
|
||||||
|
/// <param name="describer">The <see cref="IdentityErrorDescriber"/> used to describe store errors.</param>
|
||||||
|
public UserStore(TContext context, IdentityErrorDescriber describer = null) : base(context, describer) { }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a new instance of a persistence store for the specified user and role types.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="TUser">The type representing a user.</typeparam>
|
||||||
|
/// <typeparam name="TRole">The type representing a role.</typeparam>
|
||||||
|
/// <typeparam name="TContext">The type of the data context class used to access the store.</typeparam>
|
||||||
|
/// <typeparam name="TKey">The type of the primary key for a role.</typeparam>
|
||||||
|
/// <typeparam name="TUserClaim">The type representing a claim.</typeparam>
|
||||||
|
/// <typeparam name="TUserRole">The type representing a user role.</typeparam>
|
||||||
|
/// <typeparam name="TUserLogin">The type representing a user external login.</typeparam>
|
||||||
|
/// <typeparam name="TUserToken">The type representing a user token.</typeparam>
|
||||||
|
/// <typeparam name="TRoleClaim">The type representing a role claim.</typeparam>
|
||||||
|
public abstract class UserStore<TUser, TRole, TContext, TKey, TUserClaim, TUserRole, TUserLogin, TUserToken, TRoleClaim> :
|
||||||
IUserLoginStore<TUser>,
|
IUserLoginStore<TUser>,
|
||||||
IUserRoleStore<TUser>,
|
IUserRoleStore<TUser>,
|
||||||
IUserClaimStore<TUser>,
|
IUserClaimStore<TUser>,
|
||||||
|
|
@ -170,13 +202,14 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore
|
||||||
IUserTwoFactorStore<TUser>,
|
IUserTwoFactorStore<TUser>,
|
||||||
IUserAuthenticationTokenStore<TUser>
|
IUserAuthenticationTokenStore<TUser>
|
||||||
where TUser : IdentityUser<TKey, TUserClaim, TUserRole, TUserLogin>
|
where TUser : IdentityUser<TKey, TUserClaim, TUserRole, TUserLogin>
|
||||||
where TRole : IdentityRole<TKey, TUserRole, IdentityRoleClaim<TKey>>
|
where TRole : IdentityRole<TKey, TUserRole, TRoleClaim>
|
||||||
where TContext : DbContext
|
where TContext : DbContext
|
||||||
where TKey : IEquatable<TKey>
|
where TKey : IEquatable<TKey>
|
||||||
where TUserClaim : IdentityUserClaim<TKey>
|
where TUserClaim : IdentityUserClaim<TKey>
|
||||||
where TUserRole : IdentityUserRole<TKey>
|
where TUserRole : IdentityUserRole<TKey>
|
||||||
where TUserLogin : IdentityUserLogin<TKey>
|
where TUserLogin : IdentityUserLogin<TKey>
|
||||||
where TUserToken : IdentityUserToken<TKey>
|
where TUserToken : IdentityUserToken<TKey>
|
||||||
|
where TRoleClaim : IdentityRoleClaim<TKey>
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new instance of <see cref="UserStore"/>.
|
/// Creates a new instance of <see cref="UserStore"/>.
|
||||||
|
|
|
||||||
|
|
@ -199,7 +199,7 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore.Test
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class UserStoreWithGenerics : UserStore<IdentityUserWithGenerics, MyIdentityRole, ContextWithGenerics, string, IdentityUserClaimWithIssuer, IdentityUserRoleWithDate, IdentityUserLoginWithContext, IdentityUserTokenWithStuff>
|
public class UserStoreWithGenerics : UserStore<IdentityUserWithGenerics, MyIdentityRole, ContextWithGenerics, string, IdentityUserClaimWithIssuer, IdentityUserRoleWithDate, IdentityUserLoginWithContext, IdentityUserTokenWithStuff, IdentityRoleClaimWithIssuer>
|
||||||
{
|
{
|
||||||
public string LoginContext { get; set; }
|
public string LoginContext { get; set; }
|
||||||
|
|
||||||
|
|
@ -248,7 +248,7 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore.Test
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class RoleStoreWithGenerics : RoleStore<MyIdentityRole, ContextWithGenerics, string, IdentityUserRoleWithDate, IdentityRoleClaim<string>>
|
public class RoleStoreWithGenerics : RoleStore<MyIdentityRole, ContextWithGenerics, string, IdentityUserRoleWithDate, IdentityRoleClaimWithIssuer>
|
||||||
{
|
{
|
||||||
private string _loginContext;
|
private string _loginContext;
|
||||||
public RoleStoreWithGenerics(ContextWithGenerics context, string loginContext) : base(context)
|
public RoleStoreWithGenerics(ContextWithGenerics context, string loginContext) : base(context)
|
||||||
|
|
@ -256,9 +256,9 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore.Test
|
||||||
_loginContext = loginContext;
|
_loginContext = loginContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override IdentityRoleClaim<string> CreateRoleClaim(MyIdentityRole role, Claim claim)
|
protected override IdentityRoleClaimWithIssuer CreateRoleClaim(MyIdentityRole role, Claim claim)
|
||||||
{
|
{
|
||||||
return new IdentityRoleClaim<string> { RoleId = role.Id, ClaimType = claim.Type, ClaimValue = claim.Value };
|
return new IdentityRoleClaimWithIssuer { RoleId = role.Id, ClaimType = claim.Type, ClaimValue = claim.Value, Issuer = claim.Issuer };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -279,12 +279,29 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore.Test
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class IdentityRoleClaimWithIssuer : IdentityRoleClaim<string>
|
||||||
|
{
|
||||||
|
public string Issuer { get; set; }
|
||||||
|
|
||||||
|
public override Claim ToClaim()
|
||||||
|
{
|
||||||
|
return new Claim(ClaimType, ClaimValue, null, Issuer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void InitializeFromClaim(Claim other)
|
||||||
|
{
|
||||||
|
ClaimValue = other.Value;
|
||||||
|
ClaimType = other.Type;
|
||||||
|
Issuer = other.Issuer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public class IdentityUserRoleWithDate : IdentityUserRole<string>
|
public class IdentityUserRoleWithDate : IdentityUserRole<string>
|
||||||
{
|
{
|
||||||
public DateTime Created { get; set; }
|
public DateTime Created { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class MyIdentityRole : IdentityRole<string, IdentityUserRoleWithDate, IdentityRoleClaim<string>>
|
public class MyIdentityRole : IdentityRole<string, IdentityUserRoleWithDate, IdentityRoleClaimWithIssuer>
|
||||||
{
|
{
|
||||||
public MyIdentityRole() : base()
|
public MyIdentityRole() : base()
|
||||||
{
|
{
|
||||||
|
|
@ -307,7 +324,7 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore.Test
|
||||||
public string Context { get; set; }
|
public string Context { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ContextWithGenerics : IdentityDbContext<IdentityUserWithGenerics, MyIdentityRole, string, IdentityUserClaimWithIssuer, IdentityUserRoleWithDate, IdentityUserLoginWithContext, IdentityRoleClaim<string>, IdentityUserTokenWithStuff>
|
public class ContextWithGenerics : IdentityDbContext<IdentityUserWithGenerics, MyIdentityRole, string, IdentityUserClaimWithIssuer, IdentityUserRoleWithDate, IdentityUserLoginWithContext, IdentityRoleClaimWithIssuer, IdentityUserTokenWithStuff>
|
||||||
{
|
{
|
||||||
public ContextWithGenerics(DbContextOptions options) : base(options) { }
|
public ContextWithGenerics(DbContextOptions options) : base(options) { }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue