Refactor Identity into Core + Stores
This commit is contained in:
parent
e594854cd2
commit
e6f3ebf581
30
Identity.sln
30
Identity.sln
|
|
@ -54,6 +54,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Identi
|
|||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Identity.Service.InMemory.Test", "test\Microsoft.AspNetCore.Identity.Service.InMemory.Test\Microsoft.AspNetCore.Identity.Service.InMemory.Test.csproj", "{94EC586A-2AE6-4AF2-894A-B0973C65BD68}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Identity.Core", "src\Microsoft.Extensions.Identity.Core\Microsoft.Extensions.Identity.Core.csproj", "{D5905D78-A32E-44B8-8F21-EDAEDC95D9B8}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Identity.Stores", "src\Microsoft.Extensions.Identity.Stores\Microsoft.Extensions.Identity.Stores.csproj", "{FADA11FC-DC06-4832-A569-7B2374A6CD42}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
|
@ -326,6 +330,30 @@ Global
|
|||
{94EC586A-2AE6-4AF2-894A-B0973C65BD68}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{94EC586A-2AE6-4AF2-894A-B0973C65BD68}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{94EC586A-2AE6-4AF2-894A-B0973C65BD68}.Release|x86.Build.0 = Release|Any CPU
|
||||
{D5905D78-A32E-44B8-8F21-EDAEDC95D9B8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{D5905D78-A32E-44B8-8F21-EDAEDC95D9B8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D5905D78-A32E-44B8-8F21-EDAEDC95D9B8}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{D5905D78-A32E-44B8-8F21-EDAEDC95D9B8}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{D5905D78-A32E-44B8-8F21-EDAEDC95D9B8}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{D5905D78-A32E-44B8-8F21-EDAEDC95D9B8}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{D5905D78-A32E-44B8-8F21-EDAEDC95D9B8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D5905D78-A32E-44B8-8F21-EDAEDC95D9B8}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{D5905D78-A32E-44B8-8F21-EDAEDC95D9B8}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{D5905D78-A32E-44B8-8F21-EDAEDC95D9B8}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{D5905D78-A32E-44B8-8F21-EDAEDC95D9B8}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{D5905D78-A32E-44B8-8F21-EDAEDC95D9B8}.Release|x86.Build.0 = Release|Any CPU
|
||||
{FADA11FC-DC06-4832-A569-7B2374A6CD42}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{FADA11FC-DC06-4832-A569-7B2374A6CD42}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{FADA11FC-DC06-4832-A569-7B2374A6CD42}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{FADA11FC-DC06-4832-A569-7B2374A6CD42}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{FADA11FC-DC06-4832-A569-7B2374A6CD42}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{FADA11FC-DC06-4832-A569-7B2374A6CD42}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{FADA11FC-DC06-4832-A569-7B2374A6CD42}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{FADA11FC-DC06-4832-A569-7B2374A6CD42}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{FADA11FC-DC06-4832-A569-7B2374A6CD42}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{FADA11FC-DC06-4832-A569-7B2374A6CD42}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{FADA11FC-DC06-4832-A569-7B2374A6CD42}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{FADA11FC-DC06-4832-A569-7B2374A6CD42}.Release|x86.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
@ -354,5 +382,7 @@ Global
|
|||
{7423EB30-FFE9-4707-A44B-571E89A7CA15} = {52D59F18-62D2-4D17-8CF2-BE192445AF8E}
|
||||
{4F5D777E-3CFA-4EDF-BA89-4FE04BBF7A66} = {52D59F18-62D2-4D17-8CF2-BE192445AF8E}
|
||||
{94EC586A-2AE6-4AF2-894A-B0973C65BD68} = {52D59F18-62D2-4D17-8CF2-BE192445AF8E}
|
||||
{D5905D78-A32E-44B8-8F21-EDAEDC95D9B8} = {0F647068-6602-4E24-B1DC-8ED91481A50A}
|
||||
{FADA11FC-DC06-4832-A569-7B2374A6CD42} = {0F647068-6602-4E24-B1DC-8ED91481A50A}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
|
|
|||
|
|
@ -1,17 +1,14 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using IdentitySample.Models;
|
||||
using IdentitySample.Models.AccountViewModels;
|
||||
using IdentitySample.Services;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using IdentitySample.Models;
|
||||
using IdentitySample.Models.AccountViewModels;
|
||||
using IdentitySample.Services;
|
||||
|
||||
namespace IdentitySample.Controllers
|
||||
{
|
||||
|
|
|
|||
|
|
@ -9,12 +9,10 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.Identity\Microsoft.AspNetCore.Identity.csproj" />
|
||||
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.Identity.EntityFrameworkCore\Microsoft.AspNetCore.Identity.EntityFrameworkCore.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="$(AspNetCoreVersion)" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.Facebook" Version="$(AspNetCoreVersion)" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.Google" Version="$(AspNetCoreVersion)" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.Twitter" Version="$(AspNetCoreVersion)" />
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
|
||||
namespace IdentitySample.Models
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,7 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
|
||||
namespace IdentitySample.Models.ManageViewModels
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ using IdentitySample.Models;
|
|||
using IdentitySample.Services;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
|
|
|||
|
|
@ -15,14 +15,12 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore
|
|||
/// Initializes a new instance of <see cref="IdentityDbContext"/>.
|
||||
/// </summary>
|
||||
/// <param name="options">The options to be used by a <see cref="DbContext"/>.</param>
|
||||
public IdentityDbContext(DbContextOptions options) : base(options)
|
||||
{ }
|
||||
public IdentityDbContext(DbContextOptions options) : base(options) { }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="IdentityDbContext" /> class.
|
||||
/// </summary>
|
||||
protected IdentityDbContext()
|
||||
{ }
|
||||
protected IdentityDbContext() { }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -35,14 +33,12 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore
|
|||
/// Initializes a new instance of <see cref="IdentityDbContext"/>.
|
||||
/// </summary>
|
||||
/// <param name="options">The options to be used by a <see cref="DbContext"/>.</param>
|
||||
public IdentityDbContext(DbContextOptions options) : base(options)
|
||||
{ }
|
||||
public IdentityDbContext(DbContextOptions options) : base(options) { }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="IdentityDbContext" /> class.
|
||||
/// </summary>
|
||||
protected IdentityDbContext()
|
||||
{ }
|
||||
protected IdentityDbContext() { }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -57,17 +53,15 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore
|
|||
where TKey : IEquatable<TKey>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of <see cref="IdentityDbContext"/>.
|
||||
/// Initializes a new instance of the db context.
|
||||
/// </summary>
|
||||
/// <param name="options">The options to be used by a <see cref="DbContext"/>.</param>
|
||||
public IdentityDbContext(DbContextOptions options) : base(options)
|
||||
{ }
|
||||
public IdentityDbContext(DbContextOptions options) : base(options) { }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="IdentityDbContext" /> class.
|
||||
/// Initializes a new instance of the class.
|
||||
/// </summary>
|
||||
protected IdentityDbContext()
|
||||
{ }
|
||||
protected IdentityDbContext() { }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -92,17 +86,15 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore
|
|||
where TUserToken : IdentityUserToken<TKey>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of <see cref="IdentityDbContext"/>.
|
||||
/// Initializes a new instance of the class.
|
||||
/// </summary>
|
||||
/// <param name="options">The options to be used by a <see cref="DbContext"/>.</param>
|
||||
public IdentityDbContext(DbContextOptions options) : base(options)
|
||||
{ }
|
||||
public IdentityDbContext(DbContextOptions options) : base(options) { }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="IdentityDbContext" /> class.
|
||||
/// Initializes a new instance of the class.
|
||||
/// </summary>
|
||||
protected IdentityDbContext()
|
||||
{ }
|
||||
protected IdentityDbContext() { }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the <see cref="DbSet{TEntity}"/> of Users.
|
||||
|
|
@ -159,10 +151,12 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore
|
|||
b.Property(u => u.NormalizedUserName).HasMaxLength(256);
|
||||
b.Property(u => u.Email).HasMaxLength(256);
|
||||
b.Property(u => u.NormalizedEmail).HasMaxLength(256);
|
||||
b.HasMany(u => u.Claims).WithOne().HasForeignKey(uc => uc.UserId).IsRequired();
|
||||
b.HasMany(u => u.Logins).WithOne().HasForeignKey(ul => ul.UserId).IsRequired();
|
||||
b.HasMany(u => u.Roles).WithOne().HasForeignKey(ur => ur.UserId).IsRequired();
|
||||
b.HasMany(u => u.Tokens).WithOne().HasForeignKey(ut => ut.UserId).IsRequired();
|
||||
|
||||
// Replace with b.HasMany<IdentityUserClaim>().
|
||||
b.HasMany<TUserClaim>().WithOne().HasForeignKey(uc => uc.UserId).IsRequired();
|
||||
b.HasMany<TUserLogin>().WithOne().HasForeignKey(ul => ul.UserId).IsRequired();
|
||||
b.HasMany<TUserRole>().WithOne().HasForeignKey(ur => ur.UserId).IsRequired();
|
||||
b.HasMany<TUserToken>().WithOne().HasForeignKey(ut => ut.UserId).IsRequired();
|
||||
});
|
||||
|
||||
builder.Entity<TRole>(b =>
|
||||
|
|
@ -175,8 +169,8 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore
|
|||
b.Property(u => u.Name).HasMaxLength(256);
|
||||
b.Property(u => u.NormalizedName).HasMaxLength(256);
|
||||
|
||||
b.HasMany(r => r.Users).WithOne().HasForeignKey(ur => ur.RoleId).IsRequired();
|
||||
b.HasMany(r => r.Claims).WithOne().HasForeignKey(rc => rc.RoleId).IsRequired();
|
||||
b.HasMany<TUserRole>().WithOne().HasForeignKey(ur => ur.RoleId).IsRequired();
|
||||
b.HasMany<TRoleClaim>().WithOne().HasForeignKey(rc => rc.RoleId).IsRequired();
|
||||
});
|
||||
|
||||
builder.Entity<TUserClaim>(b =>
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Microsoft.AspNetCore.Identity\Microsoft.AspNetCore.Identity.csproj" />
|
||||
<ProjectReference Include="..\Microsoft.Extensions.Identity.Stores\Microsoft.Extensions.Identity.Stores.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,36 +1,103 @@
|
|||
[
|
||||
{
|
||||
"TypeId": "public abstract class Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityDbContext<T0, T1, T2, T3, T4, T5, T6, T7> : Microsoft.EntityFrameworkCore.DbContext where T0 : Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUser<T2, T3, T4, T5> where T1 : Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityRole<T2, T4, T6> where T2 : System.IEquatable<T2> where T3 : Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUserClaim<T2> where T4 : Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUserRole<T2> where T5 : Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUserLogin<T2> where T6 : Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityRoleClaim<T2> where T7 : Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUserToken<T2>",
|
||||
"Kind": "Removal"
|
||||
},
|
||||
{
|
||||
"TypeId": "public abstract class Microsoft.AspNetCore.Identity.EntityFrameworkCore.RoleStore<T0, T1, T2, T3, T4> : Microsoft.AspNetCore.Identity.IQueryableRoleStore<T0>, Microsoft.AspNetCore.Identity.IRoleClaimStore<T0> where T0 : Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityRole<T2, T3, T4> where T1 : Microsoft.EntityFrameworkCore.DbContext where T2 : System.IEquatable<T2> where T3 : Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUserRole<T2> where T4 : Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityRoleClaim<T2>",
|
||||
"Kind": "Removal"
|
||||
},
|
||||
{
|
||||
"TypeId": "public abstract class Microsoft.AspNetCore.Identity.EntityFrameworkCore.UserStore<T0, T1, T2, T3, T4, T5, T6, T7> : Microsoft.AspNetCore.Identity.IUserLoginStore<T0>, Microsoft.AspNetCore.Identity.IUserRoleStore<T0>, Microsoft.AspNetCore.Identity.IUserClaimStore<T0>, Microsoft.AspNetCore.Identity.IUserPasswordStore<T0>, Microsoft.AspNetCore.Identity.IUserSecurityStampStore<T0>, Microsoft.AspNetCore.Identity.IUserEmailStore<T0>, Microsoft.AspNetCore.Identity.IUserLockoutStore<T0>, Microsoft.AspNetCore.Identity.IUserPhoneNumberStore<T0>, Microsoft.AspNetCore.Identity.IQueryableUserStore<T0>, Microsoft.AspNetCore.Identity.IUserTwoFactorStore<T0>, Microsoft.AspNetCore.Identity.IUserAuthenticationTokenStore<T0> where T0 : Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUser<T3, T4, T5, T6> where T1 : Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityRole<T3, T5, Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityRoleClaim<T3>> where T2 : Microsoft.EntityFrameworkCore.DbContext where T3 : System.IEquatable<T3> where T4 : Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUserClaim<T3> where T5 : Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUserRole<T3> where T6 : Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUserLogin<T3> where T7 : Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUserToken<T3>",
|
||||
"Kind": "Removal"
|
||||
},
|
||||
{
|
||||
"TypeId": "public class Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUser<T0, T1, T2, T3> where T0 : System.IEquatable<T0>",
|
||||
"Kind": "Removal"
|
||||
},
|
||||
{
|
||||
"TypeId": "public class Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUser<T0> : Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUser<T0, Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUserClaim<T0>, Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUserRole<T0>, Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUserLogin<T0>> where T0 : System.IEquatable<T0>",
|
||||
"Kind": "Removal"
|
||||
},
|
||||
{
|
||||
"TypeId": "public class Microsoft.AspNetCore.Identity.EntityFrameworkCore.UserStore<T0, T1, T2, T3> : Microsoft.AspNetCore.Identity.EntityFrameworkCore.UserStore<T0, T1, T2, T3, Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUserClaim<T3>, Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUserRole<T3>, Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUserLogin<T3>, Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUserToken<T3>> where T0 : Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUser<T3> where T1 : Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityRole<T3> where T2 : Microsoft.EntityFrameworkCore.DbContext where T3 : System.IEquatable<T3>",
|
||||
"Kind": "Removal"
|
||||
},
|
||||
{
|
||||
"TypeId": "public class Microsoft.AspNetCore.Identity.EntityFrameworkCore.RoleStore<T0, T1, T2> : Microsoft.AspNetCore.Identity.EntityFrameworkCore.RoleStore<T0, T1, T2, Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUserRole<T2>, Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityRoleClaim<T2>> where T0 : Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityRole<T2> where T1 : Microsoft.EntityFrameworkCore.DbContext where T2 : System.IEquatable<T2>",
|
||||
"MemberId": "protected override Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityRoleClaim<T2> CreateRoleClaim(T0 role, System.Security.Claims.Claim claim)",
|
||||
"Kind": "Removal"
|
||||
},
|
||||
{
|
||||
"TypeId": "public static class Microsoft.Extensions.DependencyInjection.IdentityEntityFrameworkBuilderExtensions",
|
||||
"MemberId": "public static new Microsoft.AspNetCore.Identity.IdentityBuilder AddEntityFrameworkStores<T0, T1>(this Microsoft.AspNetCore.Identity.IdentityBuilder builder) where T0 : Microsoft.EntityFrameworkCore.DbContext where T1 : System.IEquatable<T1>",
|
||||
"Kind": "Removal"
|
||||
}
|
||||
{
|
||||
"TypeId": "public class Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityDbContext : Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityDbContext<Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUser, Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityRole, System.String>",
|
||||
"Kind": "Removal"
|
||||
},
|
||||
{
|
||||
"TypeId": "public class Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityDbContext<T0, T1, T2> : Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityDbContext<T0, T1, T2, Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUserClaim<T2>, Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUserRole<T2>, Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUserLogin<T2>, Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityRoleClaim<T2>, Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUserToken<T2>> where T0 : Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUser<T2> where T1 : Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityRole<T2> where T2 : System.IEquatable<T2>",
|
||||
"Kind": "Removal"
|
||||
},
|
||||
{
|
||||
"TypeId": "public class Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityDbContext<T0> : Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityDbContext<T0, Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityRole, System.String> where T0 : Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUser",
|
||||
"Kind": "Removal"
|
||||
},
|
||||
{
|
||||
"TypeId": "public class Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityRole : Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityRole<System.String>",
|
||||
"Kind": "Removal"
|
||||
},
|
||||
{
|
||||
"TypeId": "public class Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityRole<T0, T1, T2> where T0 : System.IEquatable<T0> where T1 : Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUserRole<T0> where T2 : Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityRoleClaim<T0>",
|
||||
"Kind": "Removal"
|
||||
},
|
||||
{
|
||||
"TypeId": "public class Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityRole<T0> : Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityRole<T0, Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUserRole<T0>, Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityRoleClaim<T0>> where T0 : System.IEquatable<T0>",
|
||||
"Kind": "Removal"
|
||||
},
|
||||
{
|
||||
"TypeId": "public class Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityRoleClaim<T0> where T0 : System.IEquatable<T0>",
|
||||
"Kind": "Removal"
|
||||
},
|
||||
{
|
||||
"TypeId": "public class Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUser : Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUser<System.String>",
|
||||
"Kind": "Removal"
|
||||
},
|
||||
{
|
||||
"TypeId": "public class Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUserClaim<T0> where T0 : System.IEquatable<T0>",
|
||||
"Kind": "Removal"
|
||||
},
|
||||
{
|
||||
"TypeId": "public class Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUserLogin<T0> where T0 : System.IEquatable<T0>",
|
||||
"Kind": "Removal"
|
||||
},
|
||||
{
|
||||
"TypeId": "public class Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUserRole<T0> where T0 : System.IEquatable<T0>",
|
||||
"Kind": "Removal"
|
||||
},
|
||||
{
|
||||
"TypeId": "public class Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUserToken<T0> where T0 : System.IEquatable<T0>",
|
||||
"Kind": "Removal"
|
||||
},
|
||||
{
|
||||
"TypeId": "public class Microsoft.AspNetCore.Identity.EntityFrameworkCore.RoleStore<T0, T1, T2> : Microsoft.AspNetCore.Identity.EntityFrameworkCore.RoleStore<T0, T1, T2, Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUserRole<T2>, Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityRoleClaim<T2>> where T0 : Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityRole<T2> where T1 : Microsoft.EntityFrameworkCore.DbContext where T2 : System.IEquatable<T2>",
|
||||
"Kind": "Removal"
|
||||
},
|
||||
{
|
||||
"TypeId": "public class Microsoft.AspNetCore.Identity.EntityFrameworkCore.RoleStore<T0, T1> : Microsoft.AspNetCore.Identity.EntityFrameworkCore.RoleStore<T0, T1, System.String> where T0 : Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityRole<System.String> where T1 : Microsoft.EntityFrameworkCore.DbContext",
|
||||
"Kind": "Removal"
|
||||
},
|
||||
{
|
||||
"TypeId": "public class Microsoft.AspNetCore.Identity.EntityFrameworkCore.RoleStore<T0> : Microsoft.AspNetCore.Identity.EntityFrameworkCore.RoleStore<T0, Microsoft.EntityFrameworkCore.DbContext, System.String> where T0 : Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityRole<System.String>",
|
||||
"Kind": "Removal"
|
||||
},
|
||||
{
|
||||
"TypeId": "public class Microsoft.AspNetCore.Identity.EntityFrameworkCore.UserStore : Microsoft.AspNetCore.Identity.EntityFrameworkCore.UserStore<Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUser<System.String>>",
|
||||
"Kind": "Removal"
|
||||
},
|
||||
{
|
||||
"TypeId": "public class Microsoft.AspNetCore.Identity.EntityFrameworkCore.UserStore<T0, T1, T2> : Microsoft.AspNetCore.Identity.EntityFrameworkCore.UserStore<T0, T1, T2, System.String> where T0 : Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUser<System.String> where T1 : Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityRole<System.String> where T2 : Microsoft.EntityFrameworkCore.DbContext",
|
||||
"Kind": "Removal"
|
||||
},
|
||||
{
|
||||
"TypeId": "public class Microsoft.AspNetCore.Identity.EntityFrameworkCore.UserStore<T0> : Microsoft.AspNetCore.Identity.EntityFrameworkCore.UserStore<T0, Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityRole, Microsoft.EntityFrameworkCore.DbContext, System.String> where T0 : Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUser<System.String>, new()",
|
||||
"Kind": "Removal"
|
||||
},
|
||||
{
|
||||
"TypeId": "public abstract class Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityDbContext<T0, T1, T2, T3, T4, T5, T6, T7> : Microsoft.EntityFrameworkCore.DbContext where T0 : Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUser<T2, T3, T4, T5> where T1 : Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityRole<T2, T4, T6> where T2 : System.IEquatable<T2> where T3 : Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUserClaim<T2> where T4 : Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUserRole<T2> where T5 : Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUserLogin<T2> where T6 : Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityRoleClaim<T2> where T7 : Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUserToken<T2>",
|
||||
"Kind": "Removal"
|
||||
},
|
||||
{
|
||||
"TypeId": "public abstract class Microsoft.AspNetCore.Identity.EntityFrameworkCore.RoleStore<T0, T1, T2, T3, T4> : Microsoft.AspNetCore.Identity.IQueryableRoleStore<T0>, Microsoft.AspNetCore.Identity.IRoleClaimStore<T0> where T0 : Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityRole<T2, T3, T4> where T1 : Microsoft.EntityFrameworkCore.DbContext where T2 : System.IEquatable<T2> where T3 : Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUserRole<T2> where T4 : Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityRoleClaim<T2>",
|
||||
"Kind": "Removal"
|
||||
},
|
||||
{
|
||||
"TypeId": "public abstract class Microsoft.AspNetCore.Identity.EntityFrameworkCore.UserStore<T0, T1, T2, T3, T4, T5, T6, T7> : Microsoft.AspNetCore.Identity.IUserLoginStore<T0>, Microsoft.AspNetCore.Identity.IUserRoleStore<T0>, Microsoft.AspNetCore.Identity.IUserClaimStore<T0>, Microsoft.AspNetCore.Identity.IUserPasswordStore<T0>, Microsoft.AspNetCore.Identity.IUserSecurityStampStore<T0>, Microsoft.AspNetCore.Identity.IUserEmailStore<T0>, Microsoft.AspNetCore.Identity.IUserLockoutStore<T0>, Microsoft.AspNetCore.Identity.IUserPhoneNumberStore<T0>, Microsoft.AspNetCore.Identity.IQueryableUserStore<T0>, Microsoft.AspNetCore.Identity.IUserTwoFactorStore<T0>, Microsoft.AspNetCore.Identity.IUserAuthenticationTokenStore<T0> where T0 : Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUser<T3, T4, T5, T6> where T1 : Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityRole<T3, T5, Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityRoleClaim<T3>> where T2 : Microsoft.EntityFrameworkCore.DbContext where T3 : System.IEquatable<T3> where T4 : Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUserClaim<T3> where T5 : Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUserRole<T3> where T6 : Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUserLogin<T3> where T7 : Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUserToken<T3>",
|
||||
"Kind": "Removal"
|
||||
},
|
||||
{
|
||||
"TypeId": "public class Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUser<T0, T1, T2, T3> where T0 : System.IEquatable<T0>",
|
||||
"Kind": "Removal"
|
||||
},
|
||||
{
|
||||
"TypeId": "public class Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUser<T0> : Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUser<T0, Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUserClaim<T0>, Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUserRole<T0>, Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUserLogin<T0>> where T0 : System.IEquatable<T0>",
|
||||
"Kind": "Removal"
|
||||
},
|
||||
{
|
||||
"TypeId": "public class Microsoft.AspNetCore.Identity.EntityFrameworkCore.UserStore<T0, T1, T2, T3> : Microsoft.AspNetCore.Identity.EntityFrameworkCore.UserStore<T0, T1, T2, T3, Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUserClaim<T3>, Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUserRole<T3>, Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUserLogin<T3>, Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUserToken<T3>> where T0 : Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUser<T3> where T1 : Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityRole<T3> where T2 : Microsoft.EntityFrameworkCore.DbContext where T3 : System.IEquatable<T3>",
|
||||
"Kind": "Removal"
|
||||
},
|
||||
{
|
||||
"TypeId": "public static class Microsoft.Extensions.DependencyInjection.IdentityEntityFrameworkBuilderExtensions",
|
||||
"MemberId": "public static new Microsoft.AspNetCore.Identity.IdentityBuilder AddEntityFrameworkStores<T0, T1>(this Microsoft.AspNetCore.Identity.IdentityBuilder builder) where T0 : Microsoft.EntityFrameworkCore.DbContext where T1 : System.IEquatable<T1>",
|
||||
"Kind": "Removal"
|
||||
}
|
||||
]
|
||||
|
|
@ -12,10 +12,7 @@ namespace Microsoft.AspNetCore.Identity.Service.EntityFrameworkCore
|
|||
where TUser : IdentityUser
|
||||
where TApplication : IdentityServiceApplication
|
||||
{
|
||||
public IdentityServiceDbContext(DbContextOptions options)
|
||||
: base(options)
|
||||
{
|
||||
}
|
||||
public IdentityServiceDbContext(DbContextOptions options) : base(options) { }
|
||||
}
|
||||
|
||||
public abstract class IdentityServiceDbContext<TUser,TRole,TUserKey,TApplication,TApplicationKey>
|
||||
|
|
@ -39,10 +36,7 @@ namespace Microsoft.AspNetCore.Identity.Service.EntityFrameworkCore
|
|||
where TApplication : IdentityServiceApplication<TApplicationKey,TUserKey>
|
||||
where TApplicationKey : IEquatable<TApplicationKey>
|
||||
{
|
||||
public IdentityServiceDbContext(DbContextOptions options)
|
||||
: base(options)
|
||||
{
|
||||
}
|
||||
public IdentityServiceDbContext(DbContextOptions options) : base(options) { }
|
||||
}
|
||||
|
||||
public abstract class IdentityServiceDbContext<
|
||||
|
|
@ -76,8 +70,7 @@ namespace Microsoft.AspNetCore.Identity.Service.EntityFrameworkCore
|
|||
{
|
||||
public IdentityServiceDbContext(DbContextOptions options)
|
||||
: base(options)
|
||||
{
|
||||
}
|
||||
{ }
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder builder)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ namespace Microsoft.AspNetCore.Identity.Service.Configuration
|
|||
.AddSingle(IdentityServiceClaimTypes.Name, _options.Value.ClaimsIdentity.UserNameClaimType);
|
||||
|
||||
options.LoginPolicy = new AuthorizationPolicyBuilder(options.LoginPolicy)
|
||||
.AddAuthenticationSchemes(IdentityCookieOptions.ApplicationScheme)
|
||||
.AddAuthenticationSchemes(IdentityConstants.ApplicationScheme)
|
||||
.Build();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,8 +64,8 @@ namespace Microsoft.Extensions.DependencyInjection
|
|||
options.CookiePath = $"/tfp/IdentityService";
|
||||
});
|
||||
services.ConfigureApplicationCookie(options => options.CookiePath = $"/tfp/IdentityService");
|
||||
services.Configure<CookieAuthenticationOptions>(IdentityCookieOptions.TwoFactorRememberMeScheme, options => options.CookiePath = $"/tfp/IdentityService");
|
||||
services.Configure<CookieAuthenticationOptions>(IdentityCookieOptions.TwoFactorUserIdScheme, options => options.CookiePath = $"/tfp/IdentityService");
|
||||
services.Configure<CookieAuthenticationOptions>(IdentityConstants.TwoFactorRememberMeScheme, options => options.CookiePath = $"/tfp/IdentityService");
|
||||
services.Configure<CookieAuthenticationOptions>(IdentityConstants.TwoFactorUserIdScheme, options => options.CookiePath = $"/tfp/IdentityService");
|
||||
|
||||
services.AddTransient<IConfigureOptions<AuthorizationOptions>, IdentityServiceAuthorizationOptionsSetup>();
|
||||
|
||||
|
|
|
|||
|
|
@ -6,14 +6,12 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Security.Claims;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNetCore.Identity.Test
|
||||
|
|
@ -2084,7 +2082,7 @@ namespace Microsoft.AspNetCore.Identity.Test
|
|||
var stamp = await manager.GetSecurityStampAsync(user);
|
||||
IdentityResultAssert.IsFailure(await manager.ChangePhoneNumberAsync(user, "111-111-1111", "bogus"),
|
||||
"Invalid token.");
|
||||
IdentityResultAssert.VerifyLogMessage(manager.Logger, $"VerifyChangePhoneNumberTokenAsync() failed for user {await manager.GetUserIdAsync(user)}.");
|
||||
IdentityResultAssert.VerifyLogMessage(manager.Logger, $"VerifyUserTokenAsync() failed with purpose: ChangePhoneNumber:111-111-1111 for user { await manager.GetUserIdAsync(user)}.");
|
||||
Assert.False(await manager.IsPhoneNumberConfirmedAsync(user));
|
||||
Assert.Equal("123-456-7890", await manager.GetPhoneNumberAsync(user));
|
||||
Assert.Equal(stamp, await manager.GetSecurityStampAsync(user));
|
||||
|
|
@ -2139,7 +2137,7 @@ namespace Microsoft.AspNetCore.Identity.Test
|
|||
Assert.True(await manager.VerifyChangePhoneNumberTokenAsync(user, token2, num2));
|
||||
Assert.False(await manager.VerifyChangePhoneNumberTokenAsync(user, token2, num1));
|
||||
Assert.False(await manager.VerifyChangePhoneNumberTokenAsync(user, token1, num2));
|
||||
IdentityResultAssert.VerifyLogMessage(manager.Logger, $"VerifyChangePhoneNumberTokenAsync() failed for user {await manager.GetUserIdAsync(user)}.");
|
||||
IdentityResultAssert.VerifyLogMessage(manager.Logger, $"VerifyUserTokenAsync() failed with purpose: ChangePhoneNumber:111-123-4567 for user {await manager.GetUserIdAsync(user)}.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,45 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Microsoft.AspNetCore.Identity
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides the APIs for managing roles in a persistence store.
|
||||
/// </summary>
|
||||
/// <typeparam name="TRole">The type encapsulating a role.</typeparam>
|
||||
public class AspNetRoleManager<TRole> : RoleManager<TRole>, IDisposable where TRole : class
|
||||
{
|
||||
private readonly CancellationToken _cancel;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new instance of <see cref="RoleManager{TRole}"/>.
|
||||
/// </summary>
|
||||
/// <param name="store">The persistence store the manager will operate over.</param>
|
||||
/// <param name="roleValidators">A collection of validators for roles.</param>
|
||||
/// <param name="keyNormalizer">The normalizer to use when normalizing role names to keys.</param>
|
||||
/// <param name="errors">The <see cref="IdentityErrorDescriber"/> used to provider error messages.</param>
|
||||
/// <param name="logger">The logger used to log messages, warnings and errors.</param>
|
||||
/// <param name="contextAccessor">The accessor used to access the <see cref="HttpContext"/>.</param>
|
||||
public AspNetRoleManager(IRoleStore<TRole> store,
|
||||
IEnumerable<IRoleValidator<TRole>> roleValidators,
|
||||
ILookupNormalizer keyNormalizer,
|
||||
IdentityErrorDescriber errors,
|
||||
ILogger<RoleManager<TRole>> logger,
|
||||
IHttpContextAccessor contextAccessor)
|
||||
: base(store, roleValidators, keyNormalizer, errors, logger)
|
||||
{
|
||||
_cancel = contextAccessor?.HttpContext?.RequestAborted ?? CancellationToken.None;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The cancellation token assocated with the current HttpContext.RequestAborted or CancellationToken.None if unavailable.
|
||||
/// </summary>
|
||||
protected override CancellationToken CancellationToken => _cancel;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
namespace Microsoft.AspNetCore.Identity
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides the APIs for managing user in a persistence store.
|
||||
/// </summary>
|
||||
/// <typeparam name="TUser">The type encapsulating a user.</typeparam>
|
||||
public class AspNetUserManager<TUser> : UserManager<TUser>, IDisposable where TUser : class
|
||||
{
|
||||
private readonly CancellationToken _cancel;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new instance of <see cref="AspNetUserManager{TUser}"/>.
|
||||
/// </summary>
|
||||
/// <param name="store">The persistence store the manager will operate over.</param>
|
||||
/// <param name="optionsAccessor">The accessor used to access the <see cref="IdentityOptions"/>.</param>
|
||||
/// <param name="passwordHasher">The password hashing implementation to use when saving passwords.</param>
|
||||
/// <param name="userValidators">A collection of <see cref="IUserValidator{TUser}"/> to validate users against.</param>
|
||||
/// <param name="passwordValidators">A collection of <see cref="IPasswordValidator{TUser}"/> to validate passwords against.</param>
|
||||
/// <param name="keyNormalizer">The <see cref="ILookupNormalizer"/> to use when generating index keys for users.</param>
|
||||
/// <param name="errors">The <see cref="IdentityErrorDescriber"/> used to provider error messages.</param>
|
||||
/// <param name="services">The <see cref="IServiceProvider"/> used to resolve services.</param>
|
||||
/// <param name="logger">The logger used to log messages, warnings and errors.</param>
|
||||
public AspNetUserManager(IUserStore<TUser> store,
|
||||
IOptions<IdentityOptions> optionsAccessor,
|
||||
IPasswordHasher<TUser> passwordHasher,
|
||||
IEnumerable<IUserValidator<TUser>> userValidators,
|
||||
IEnumerable<IPasswordValidator<TUser>> passwordValidators,
|
||||
ILookupNormalizer keyNormalizer,
|
||||
IdentityErrorDescriber errors,
|
||||
IServiceProvider services,
|
||||
ILogger<UserManager<TUser>> logger)
|
||||
: base(store, optionsAccessor, passwordHasher, userValidators, passwordValidators, keyNormalizer, errors, services, logger)
|
||||
{
|
||||
_cancel = services?.GetService<IHttpContextAccessor>()?.HttpContext?.RequestAborted ?? CancellationToken.None;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The cancellation token assocated with the current HttpContext.RequestAborted or CancellationToken.None if unavailable.
|
||||
/// </summary>
|
||||
protected override CancellationToken CancellationToken => _cancel;
|
||||
}
|
||||
}
|
||||
|
|
@ -4,7 +4,6 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.DataProtection;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
|
|
|||
|
|
@ -149,7 +149,7 @@ namespace Microsoft.AspNetCore.Identity
|
|||
{
|
||||
if (!typeof(IUserTwoFactorTokenProvider<>).MakeGenericType(UserType).GetTypeInfo().IsAssignableFrom(provider.GetTypeInfo()))
|
||||
{
|
||||
throw new InvalidOperationException(Resources.FormatInvalidManagerType(provider.Name, "IUserTokenProvider", UserType.Name));
|
||||
throw new InvalidOperationException(AspNetIdentityResources.FormatInvalidManagerType(provider.Name, "IUserTokenProvider", UserType.Name));
|
||||
}
|
||||
Services.Configure<IdentityOptions>(options =>
|
||||
{
|
||||
|
|
@ -188,7 +188,7 @@ namespace Microsoft.AspNetCore.Identity
|
|||
if (userManagerType == customType ||
|
||||
!userManagerType.GetTypeInfo().IsAssignableFrom(customType.GetTypeInfo()))
|
||||
{
|
||||
throw new InvalidOperationException(Resources.FormatInvalidManagerType(customType.Name, "UserManager", UserType.Name));
|
||||
throw new InvalidOperationException(AspNetIdentityResources.FormatInvalidManagerType(customType.Name, "UserManager", UserType.Name));
|
||||
}
|
||||
Services.AddScoped(customType, services => services.GetRequiredService(userManagerType));
|
||||
return AddScoped(userManagerType, customType);
|
||||
|
|
@ -206,7 +206,7 @@ namespace Microsoft.AspNetCore.Identity
|
|||
if (managerType == customType ||
|
||||
!managerType.GetTypeInfo().IsAssignableFrom(customType.GetTypeInfo()))
|
||||
{
|
||||
throw new InvalidOperationException(Resources.FormatInvalidManagerType(customType.Name, "RoleManager", RoleType.Name));
|
||||
throw new InvalidOperationException(AspNetIdentityResources.FormatInvalidManagerType(customType.Name, "RoleManager", RoleType.Name));
|
||||
}
|
||||
Services.AddScoped(typeof(TRoleManager), services => services.GetRequiredService(managerType));
|
||||
return AddScoped(managerType, typeof(TRoleManager));
|
||||
|
|
@ -224,7 +224,7 @@ namespace Microsoft.AspNetCore.Identity
|
|||
if (managerType == customType ||
|
||||
!managerType.GetTypeInfo().IsAssignableFrom(customType.GetTypeInfo()))
|
||||
{
|
||||
throw new InvalidOperationException(Resources.FormatInvalidManagerType(customType.Name, "SignInManager", UserType.Name));
|
||||
throw new InvalidOperationException(AspNetIdentityResources.FormatInvalidManagerType(customType.Name, "SignInManager", UserType.Name));
|
||||
}
|
||||
Services.AddScoped(typeof(TSignInManager), services => services.GetRequiredService(managerType));
|
||||
return AddScoped(managerType, typeof(TSignInManager));
|
||||
|
|
|
|||
|
|
@ -0,0 +1,32 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
namespace Microsoft.AspNetCore.Identity
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents all the options you can use to configure the cookies middleware uesd by the identity system.
|
||||
/// </summary>
|
||||
public class IdentityConstants
|
||||
{
|
||||
private static readonly string CookiePrefix = "Identity";
|
||||
/// <summary>
|
||||
/// The scheme used to identify application authentication cookies.
|
||||
/// </summary>
|
||||
public static readonly string ApplicationScheme = CookiePrefix + ".Application";
|
||||
|
||||
/// <summary>
|
||||
/// The scheme used to identify external authentication cookies.
|
||||
/// </summary>
|
||||
public static readonly string ExternalScheme = CookiePrefix + ".External";
|
||||
|
||||
/// <summary>
|
||||
/// The scheme used to identify Two Factor authentication cookies for saving the Remember Me state.
|
||||
/// </summary>
|
||||
public static readonly string TwoFactorRememberMeScheme = CookiePrefix + ".TwoFactorRememberMe";
|
||||
|
||||
/// <summary>
|
||||
/// The scheme used to identify Two Factor authentication cookies for round tripping user identities.
|
||||
/// </summary>
|
||||
public static readonly string TwoFactorUserIdScheme = CookiePrefix + ".TwoFactorUserId";
|
||||
}
|
||||
}
|
||||
|
|
@ -1,83 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using Microsoft.AspNetCore.Authentication.Cookies;
|
||||
|
||||
namespace Microsoft.AspNetCore.Identity
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents all the options you can use to configure the cookies middleware uesd by the identity system.
|
||||
/// </summary>
|
||||
public class IdentityCookieOptions
|
||||
{
|
||||
private static readonly string CookiePrefix = "Identity";
|
||||
/// <summary>
|
||||
/// The scheme used to identify application authentication cookies.
|
||||
/// </summary>
|
||||
public static readonly string ApplicationScheme = CookiePrefix + ".Application";
|
||||
|
||||
/// <summary>
|
||||
/// The scheme used to identify external authentication cookies.
|
||||
/// </summary>
|
||||
public static readonly string ExternalScheme = CookiePrefix + ".External";
|
||||
|
||||
/// <summary>
|
||||
/// The scheme used to identify Two Factor authentication cookies for saving the Remember Me state.
|
||||
/// </summary>
|
||||
public static readonly string TwoFactorRememberMeScheme = CookiePrefix + ".TwoFactorRememberMe";
|
||||
|
||||
/// <summary>
|
||||
/// The scheme used to identify Two Factor authentication cookies for round tripping user identities.
|
||||
/// </summary>
|
||||
public static readonly string TwoFactorUserIdScheme = CookiePrefix + ".TwoFactorUserId";
|
||||
|
||||
/// <summary>
|
||||
/// The options for the application cookie.
|
||||
/// </summary>
|
||||
[Obsolete("See https://go.microsoft.com/fwlink/?linkid=845470", error: true)]
|
||||
public CookieAuthenticationOptions ApplicationCookie { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The options for the external cookie.
|
||||
/// </summary>
|
||||
[Obsolete("See https://go.microsoft.com/fwlink/?linkid=845470", error: true)]
|
||||
public CookieAuthenticationOptions ExternalCookie { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The options for the two factor remember me cookie.
|
||||
/// </summary>
|
||||
[Obsolete("See https://go.microsoft.com/fwlink/?linkid=845470", error: true)]
|
||||
public CookieAuthenticationOptions TwoFactorRememberMeCookie { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The options for the two factor user id cookie.
|
||||
/// </summary>
|
||||
[Obsolete("See https://go.microsoft.com/fwlink/?linkid=845470", error: true)]
|
||||
public CookieAuthenticationOptions TwoFactorUserIdCookie { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the scheme used to identify application authentication cookies.
|
||||
/// </summary>
|
||||
/// <value>The scheme used to identify application authentication cookies.</value>
|
||||
public string ApplicationCookieAuthenticationScheme { get; set; } = ApplicationScheme;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the scheme used to identify external authentication cookies.
|
||||
/// </summary>
|
||||
/// <value>The scheme used to identify external authentication cookies.</value>
|
||||
public string ExternalCookieAuthenticationScheme { get; set; } = ExternalScheme;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the scheme used to identify Two Factor authentication cookies for round tripping user identities.
|
||||
/// </summary>
|
||||
/// <value>The scheme used to identify user identity 2fa authentication cookies.</value>
|
||||
public string TwoFactorUserIdCookieAuthenticationScheme { get; set; } = TwoFactorUserIdScheme;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the scheme used to identify Two Factor authentication cookies for saving the Remember Me state.
|
||||
/// </summary>
|
||||
/// <value>The scheme used to identify remember me application authentication cookies.</value>
|
||||
public string TwoFactorRememberMeCookieAuthenticationScheme { get; set; } = TwoFactorRememberMeScheme;
|
||||
}
|
||||
}
|
||||
|
|
@ -46,7 +46,7 @@ namespace Microsoft.Extensions.DependencyInjection
|
|||
/// <param name="configure">An action to configure the <see cref="CookieAuthenticationOptions"/>.</param>
|
||||
/// <returns>The services.</returns>
|
||||
public static IServiceCollection ConfigureApplicationCookie(this IServiceCollection services, Action<CookieAuthenticationOptions> configure)
|
||||
=> services.Configure(IdentityCookieOptions.ApplicationScheme, configure);
|
||||
=> services.Configure(IdentityConstants.ApplicationScheme, configure);
|
||||
|
||||
/// <summary>
|
||||
/// Configure the external cookie.
|
||||
|
|
@ -55,7 +55,7 @@ namespace Microsoft.Extensions.DependencyInjection
|
|||
/// <param name="configure">An action to configure the <see cref="CookieAuthenticationOptions"/>.</param>
|
||||
/// <returns>The services.</returns>
|
||||
public static IServiceCollection ConfigureExternalCookie(this IServiceCollection services, Action<CookieAuthenticationOptions> configure)
|
||||
=> services.Configure(IdentityCookieOptions.ExternalScheme, configure);
|
||||
=> services.Configure(IdentityConstants.ExternalScheme, configure);
|
||||
|
||||
/// <summary>
|
||||
/// Adds and configures the identity system for the specified User and Role types.
|
||||
|
|
@ -74,12 +74,12 @@ namespace Microsoft.Extensions.DependencyInjection
|
|||
// Services used by identity
|
||||
services.AddAuthenticationCore(options =>
|
||||
{
|
||||
options.DefaultAuthenticateScheme = IdentityCookieOptions.ApplicationScheme;
|
||||
options.DefaultChallengeScheme = IdentityCookieOptions.ApplicationScheme;
|
||||
options.DefaultSignInScheme = IdentityCookieOptions.ExternalScheme;
|
||||
options.DefaultAuthenticateScheme = IdentityConstants.ApplicationScheme;
|
||||
options.DefaultChallengeScheme = IdentityConstants.ApplicationScheme;
|
||||
options.DefaultSignInScheme = IdentityConstants.ExternalScheme;
|
||||
});
|
||||
|
||||
services.AddCookieAuthentication(IdentityCookieOptions.ApplicationScheme, o =>
|
||||
services.AddCookieAuthentication(IdentityConstants.ApplicationScheme, o =>
|
||||
{
|
||||
o.LoginPath = new PathString("/Account/Login");
|
||||
o.Events = new CookieAuthenticationEvents
|
||||
|
|
@ -88,18 +88,18 @@ namespace Microsoft.Extensions.DependencyInjection
|
|||
};
|
||||
});
|
||||
|
||||
services.AddCookieAuthentication(IdentityCookieOptions.ExternalScheme, o =>
|
||||
services.AddCookieAuthentication(IdentityConstants.ExternalScheme, o =>
|
||||
{
|
||||
o.CookieName = IdentityCookieOptions.ExternalScheme;
|
||||
o.CookieName = IdentityConstants.ExternalScheme;
|
||||
o.ExpireTimeSpan = TimeSpan.FromMinutes(5);
|
||||
});
|
||||
|
||||
services.AddCookieAuthentication(IdentityCookieOptions.TwoFactorRememberMeScheme,
|
||||
o => o.CookieName = IdentityCookieOptions.TwoFactorRememberMeScheme);
|
||||
services.AddCookieAuthentication(IdentityConstants.TwoFactorRememberMeScheme,
|
||||
o => o.CookieName = IdentityConstants.TwoFactorRememberMeScheme);
|
||||
|
||||
services.AddCookieAuthentication(IdentityCookieOptions.TwoFactorUserIdScheme, o =>
|
||||
services.AddCookieAuthentication(IdentityConstants.TwoFactorUserIdScheme, o =>
|
||||
{
|
||||
o.CookieName = IdentityCookieOptions.TwoFactorUserIdScheme;
|
||||
o.CookieName = IdentityConstants.TwoFactorUserIdScheme;
|
||||
o.ExpireTimeSpan = TimeSpan.FromMinutes(5);
|
||||
});
|
||||
|
||||
|
|
@ -115,9 +115,9 @@ namespace Microsoft.Extensions.DependencyInjection
|
|||
services.TryAddScoped<IdentityErrorDescriber>();
|
||||
services.TryAddScoped<ISecurityStampValidator, SecurityStampValidator<TUser>>();
|
||||
services.TryAddScoped<IUserClaimsPrincipalFactory<TUser>, UserClaimsPrincipalFactory<TUser, TRole>>();
|
||||
services.TryAddScoped<UserManager<TUser>, UserManager<TUser>>();
|
||||
services.TryAddScoped<UserManager<TUser>, AspNetUserManager<TUser>>();
|
||||
services.TryAddScoped<SignInManager<TUser>, SignInManager<TUser>>();
|
||||
services.TryAddScoped<RoleManager<TRole>, RoleManager<TRole>>();
|
||||
services.TryAddScoped<RoleManager<TRole>, AspNetRoleManager<TRole>>();
|
||||
|
||||
services.AddSingleton<IConfigureOptions<IdentityOptions>, IdentityConfigureOptions>();
|
||||
if (setupAction != null)
|
||||
|
|
|
|||
|
|
@ -18,4 +18,8 @@
|
|||
<PackageReference Include="Microsoft.Extensions.TaskCache.Sources" Version="$(AspNetCoreVersion)" PrivateAssets="All" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Microsoft.Extensions.Identity.Core\Microsoft.Extensions.Identity.Core.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -53,12 +53,12 @@ namespace Microsoft.AspNetCore.Identity
|
|||
_iterCount = options.IterationCount;
|
||||
if (_iterCount < 1)
|
||||
{
|
||||
throw new InvalidOperationException(Resources.InvalidPasswordHasherIterationCount);
|
||||
throw new InvalidOperationException(AspNetIdentityResources.InvalidPasswordHasherIterationCount);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new InvalidOperationException(Resources.InvalidPasswordHasherCompatibilityMode);
|
||||
throw new InvalidOperationException(AspNetIdentityResources.InvalidPasswordHasherCompatibilityMode);
|
||||
}
|
||||
|
||||
_rng = options.Rng;
|
||||
|
|
|
|||
|
|
@ -5,106 +5,10 @@ namespace Microsoft.AspNetCore.Identity
|
|||
using System.Reflection;
|
||||
using System.Resources;
|
||||
|
||||
internal static class Resources
|
||||
internal static class AspNetIdentityResources
|
||||
{
|
||||
private static readonly ResourceManager _resourceManager
|
||||
= new ResourceManager("Microsoft.AspNetCore.Identity.Resources", typeof(Resources).GetTypeInfo().Assembly);
|
||||
|
||||
/// <summary>
|
||||
/// Optimistic concurrency failure, object has been modified.
|
||||
/// </summary>
|
||||
internal static string ConcurrencyFailure
|
||||
{
|
||||
get { return GetString("ConcurrencyFailure"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Optimistic concurrency failure, object has been modified.
|
||||
/// </summary>
|
||||
internal static string FormatConcurrencyFailure()
|
||||
{
|
||||
return GetString("ConcurrencyFailure");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An unknown failure has occurred.
|
||||
/// </summary>
|
||||
internal static string DefaultError
|
||||
{
|
||||
get { return GetString("DefaultError"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An unknown failure has occurred.
|
||||
/// </summary>
|
||||
internal static string FormatDefaultError()
|
||||
{
|
||||
return GetString("DefaultError");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Email '{0}' is already taken.
|
||||
/// </summary>
|
||||
internal static string DuplicateEmail
|
||||
{
|
||||
get { return GetString("DuplicateEmail"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Email '{0}' is already taken.
|
||||
/// </summary>
|
||||
internal static string FormatDuplicateEmail(object p0)
|
||||
{
|
||||
return string.Format(CultureInfo.CurrentCulture, GetString("DuplicateEmail"), p0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Role name '{0}' is already taken.
|
||||
/// </summary>
|
||||
internal static string DuplicateRoleName
|
||||
{
|
||||
get { return GetString("DuplicateRoleName"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Role name '{0}' is already taken.
|
||||
/// </summary>
|
||||
internal static string FormatDuplicateRoleName(object p0)
|
||||
{
|
||||
return string.Format(CultureInfo.CurrentCulture, GetString("DuplicateRoleName"), p0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// User name '{0}' is already taken.
|
||||
/// </summary>
|
||||
internal static string DuplicateUserName
|
||||
{
|
||||
get { return GetString("DuplicateUserName"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// User name '{0}' is already taken.
|
||||
/// </summary>
|
||||
internal static string FormatDuplicateUserName(object p0)
|
||||
{
|
||||
return string.Format(CultureInfo.CurrentCulture, GetString("DuplicateUserName"), p0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Email '{0}' is invalid.
|
||||
/// </summary>
|
||||
internal static string InvalidEmail
|
||||
{
|
||||
get { return GetString("InvalidEmail"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Email '{0}' is invalid.
|
||||
/// </summary>
|
||||
internal static string FormatInvalidEmail(object p0)
|
||||
{
|
||||
return string.Format(CultureInfo.CurrentCulture, GetString("InvalidEmail"), p0);
|
||||
}
|
||||
= new ResourceManager("Microsoft.AspNetCore.Identity.Resources", typeof(AspNetIdentityResources).GetTypeInfo().Assembly);
|
||||
|
||||
/// <summary>
|
||||
/// Type {0} must derive from {1}<{2}>.
|
||||
|
|
@ -154,614 +58,6 @@ namespace Microsoft.AspNetCore.Identity
|
|||
return GetString("InvalidPasswordHasherIterationCount");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Role name '{0}' is invalid.
|
||||
/// </summary>
|
||||
internal static string InvalidRoleName
|
||||
{
|
||||
get { return GetString("InvalidRoleName"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Role name '{0}' is invalid.
|
||||
/// </summary>
|
||||
internal static string FormatInvalidRoleName(object p0)
|
||||
{
|
||||
return string.Format(CultureInfo.CurrentCulture, GetString("InvalidRoleName"), p0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invalid token.
|
||||
/// </summary>
|
||||
internal static string InvalidToken
|
||||
{
|
||||
get { return GetString("InvalidToken"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invalid token.
|
||||
/// </summary>
|
||||
internal static string FormatInvalidToken()
|
||||
{
|
||||
return GetString("InvalidToken");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// User name '{0}' is invalid, can only contain letters or digits.
|
||||
/// </summary>
|
||||
internal static string InvalidUserName
|
||||
{
|
||||
get { return GetString("InvalidUserName"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// User name '{0}' is invalid, can only contain letters or digits.
|
||||
/// </summary>
|
||||
internal static string FormatInvalidUserName(object p0)
|
||||
{
|
||||
return string.Format(CultureInfo.CurrentCulture, GetString("InvalidUserName"), p0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A user with this login already exists.
|
||||
/// </summary>
|
||||
internal static string LoginAlreadyAssociated
|
||||
{
|
||||
get { return GetString("LoginAlreadyAssociated"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A user with this login already exists.
|
||||
/// </summary>
|
||||
internal static string FormatLoginAlreadyAssociated()
|
||||
{
|
||||
return GetString("LoginAlreadyAssociated");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// AddIdentity must be called on the service collection.
|
||||
/// </summary>
|
||||
internal static string MustCallAddIdentity
|
||||
{
|
||||
get { return GetString("MustCallAddIdentity"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// AddIdentity must be called on the service collection.
|
||||
/// </summary>
|
||||
internal static string FormatMustCallAddIdentity()
|
||||
{
|
||||
return GetString("MustCallAddIdentity");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// No IUserTokenProvider named '{0}' is registered.
|
||||
/// </summary>
|
||||
internal static string NoTokenProvider
|
||||
{
|
||||
get { return GetString("NoTokenProvider"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// No IUserTokenProvider named '{0}' is registered.
|
||||
/// </summary>
|
||||
internal static string FormatNoTokenProvider(object p0)
|
||||
{
|
||||
return string.Format(CultureInfo.CurrentCulture, GetString("NoTokenProvider"), p0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// User security stamp cannot be null.
|
||||
/// </summary>
|
||||
internal static string NullSecurityStamp
|
||||
{
|
||||
get { return GetString("NullSecurityStamp"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// User security stamp cannot be null.
|
||||
/// </summary>
|
||||
internal static string FormatNullSecurityStamp()
|
||||
{
|
||||
return GetString("NullSecurityStamp");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Incorrect password.
|
||||
/// </summary>
|
||||
internal static string PasswordMismatch
|
||||
{
|
||||
get { return GetString("PasswordMismatch"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Incorrect password.
|
||||
/// </summary>
|
||||
internal static string FormatPasswordMismatch()
|
||||
{
|
||||
return GetString("PasswordMismatch");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Passwords must have at least one digit ('0'-'9').
|
||||
/// </summary>
|
||||
internal static string PasswordRequiresDigit
|
||||
{
|
||||
get { return GetString("PasswordRequiresDigit"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Passwords must have at least one digit ('0'-'9').
|
||||
/// </summary>
|
||||
internal static string FormatPasswordRequiresDigit()
|
||||
{
|
||||
return GetString("PasswordRequiresDigit");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Passwords must have at least one lowercase ('a'-'z').
|
||||
/// </summary>
|
||||
internal static string PasswordRequiresLower
|
||||
{
|
||||
get { return GetString("PasswordRequiresLower"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Passwords must have at least one lowercase ('a'-'z').
|
||||
/// </summary>
|
||||
internal static string FormatPasswordRequiresLower()
|
||||
{
|
||||
return GetString("PasswordRequiresLower");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Passwords must have at least one non alphanumeric character.
|
||||
/// </summary>
|
||||
internal static string PasswordRequiresNonAlphanumeric
|
||||
{
|
||||
get { return GetString("PasswordRequiresNonAlphanumeric"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Passwords must have at least one non alphanumeric character.
|
||||
/// </summary>
|
||||
internal static string FormatPasswordRequiresNonAlphanumeric()
|
||||
{
|
||||
return GetString("PasswordRequiresNonAlphanumeric");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Passwords must have at least one uppercase ('A'-'Z').
|
||||
/// </summary>
|
||||
internal static string PasswordRequiresUpper
|
||||
{
|
||||
get { return GetString("PasswordRequiresUpper"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Passwords must have at least one uppercase ('A'-'Z').
|
||||
/// </summary>
|
||||
internal static string FormatPasswordRequiresUpper()
|
||||
{
|
||||
return GetString("PasswordRequiresUpper");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Passwords must be at least {0} characters.
|
||||
/// </summary>
|
||||
internal static string PasswordTooShort
|
||||
{
|
||||
get { return GetString("PasswordTooShort"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Passwords must be at least {0} characters.
|
||||
/// </summary>
|
||||
internal static string FormatPasswordTooShort(object p0)
|
||||
{
|
||||
return string.Format(CultureInfo.CurrentCulture, GetString("PasswordTooShort"), p0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Role {0} does not exist.
|
||||
/// </summary>
|
||||
internal static string RoleNotFound
|
||||
{
|
||||
get { return GetString("RoleNotFound"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Role {0} does not exist.
|
||||
/// </summary>
|
||||
internal static string FormatRoleNotFound(object p0)
|
||||
{
|
||||
return string.Format(CultureInfo.CurrentCulture, GetString("RoleNotFound"), p0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Store does not implement IQueryableRoleStore<TRole>.
|
||||
/// </summary>
|
||||
internal static string StoreNotIQueryableRoleStore
|
||||
{
|
||||
get { return GetString("StoreNotIQueryableRoleStore"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Store does not implement IQueryableRoleStore<TRole>.
|
||||
/// </summary>
|
||||
internal static string FormatStoreNotIQueryableRoleStore()
|
||||
{
|
||||
return GetString("StoreNotIQueryableRoleStore");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Store does not implement IQueryableUserStore<TUser>.
|
||||
/// </summary>
|
||||
internal static string StoreNotIQueryableUserStore
|
||||
{
|
||||
get { return GetString("StoreNotIQueryableUserStore"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Store does not implement IQueryableUserStore<TUser>.
|
||||
/// </summary>
|
||||
internal static string FormatStoreNotIQueryableUserStore()
|
||||
{
|
||||
return GetString("StoreNotIQueryableUserStore");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Store does not implement IRoleClaimStore<TRole>.
|
||||
/// </summary>
|
||||
internal static string StoreNotIRoleClaimStore
|
||||
{
|
||||
get { return GetString("StoreNotIRoleClaimStore"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Store does not implement IRoleClaimStore<TRole>.
|
||||
/// </summary>
|
||||
internal static string FormatStoreNotIRoleClaimStore()
|
||||
{
|
||||
return GetString("StoreNotIRoleClaimStore");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Store does not implement IUserAuthenticationTokenStore<User>.
|
||||
/// </summary>
|
||||
internal static string StoreNotIUserAuthenticationTokenStore
|
||||
{
|
||||
get { return GetString("StoreNotIUserAuthenticationTokenStore"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Store does not implement IUserAuthenticationTokenStore<User>.
|
||||
/// </summary>
|
||||
internal static string FormatStoreNotIUserAuthenticationTokenStore()
|
||||
{
|
||||
return GetString("StoreNotIUserAuthenticationTokenStore");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Store does not implement IUserClaimStore<TUser>.
|
||||
/// </summary>
|
||||
internal static string StoreNotIUserClaimStore
|
||||
{
|
||||
get { return GetString("StoreNotIUserClaimStore"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Store does not implement IUserClaimStore<TUser>.
|
||||
/// </summary>
|
||||
internal static string FormatStoreNotIUserClaimStore()
|
||||
{
|
||||
return GetString("StoreNotIUserClaimStore");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Store does not implement IUserConfirmationStore<TUser>.
|
||||
/// </summary>
|
||||
internal static string StoreNotIUserConfirmationStore
|
||||
{
|
||||
get { return GetString("StoreNotIUserConfirmationStore"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Store does not implement IUserConfirmationStore<TUser>.
|
||||
/// </summary>
|
||||
internal static string FormatStoreNotIUserConfirmationStore()
|
||||
{
|
||||
return GetString("StoreNotIUserConfirmationStore");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Store does not implement IUserEmailStore<TUser>.
|
||||
/// </summary>
|
||||
internal static string StoreNotIUserEmailStore
|
||||
{
|
||||
get { return GetString("StoreNotIUserEmailStore"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Store does not implement IUserEmailStore<TUser>.
|
||||
/// </summary>
|
||||
internal static string FormatStoreNotIUserEmailStore()
|
||||
{
|
||||
return GetString("StoreNotIUserEmailStore");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Store does not implement IUserLockoutStore<TUser>.
|
||||
/// </summary>
|
||||
internal static string StoreNotIUserLockoutStore
|
||||
{
|
||||
get { return GetString("StoreNotIUserLockoutStore"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Store does not implement IUserLockoutStore<TUser>.
|
||||
/// </summary>
|
||||
internal static string FormatStoreNotIUserLockoutStore()
|
||||
{
|
||||
return GetString("StoreNotIUserLockoutStore");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Store does not implement IUserLoginStore<TUser>.
|
||||
/// </summary>
|
||||
internal static string StoreNotIUserLoginStore
|
||||
{
|
||||
get { return GetString("StoreNotIUserLoginStore"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Store does not implement IUserLoginStore<TUser>.
|
||||
/// </summary>
|
||||
internal static string FormatStoreNotIUserLoginStore()
|
||||
{
|
||||
return GetString("StoreNotIUserLoginStore");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Store does not implement IUserPasswordStore<TUser>.
|
||||
/// </summary>
|
||||
internal static string StoreNotIUserPasswordStore
|
||||
{
|
||||
get { return GetString("StoreNotIUserPasswordStore"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Store does not implement IUserPasswordStore<TUser>.
|
||||
/// </summary>
|
||||
internal static string FormatStoreNotIUserPasswordStore()
|
||||
{
|
||||
return GetString("StoreNotIUserPasswordStore");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Store does not implement IUserPhoneNumberStore<TUser>.
|
||||
/// </summary>
|
||||
internal static string StoreNotIUserPhoneNumberStore
|
||||
{
|
||||
get { return GetString("StoreNotIUserPhoneNumberStore"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Store does not implement IUserPhoneNumberStore<TUser>.
|
||||
/// </summary>
|
||||
internal static string FormatStoreNotIUserPhoneNumberStore()
|
||||
{
|
||||
return GetString("StoreNotIUserPhoneNumberStore");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Store does not implement IUserRoleStore<TUser>.
|
||||
/// </summary>
|
||||
internal static string StoreNotIUserRoleStore
|
||||
{
|
||||
get { return GetString("StoreNotIUserRoleStore"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Store does not implement IUserRoleStore<TUser>.
|
||||
/// </summary>
|
||||
internal static string FormatStoreNotIUserRoleStore()
|
||||
{
|
||||
return GetString("StoreNotIUserRoleStore");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Store does not implement IUserSecurityStampStore<TUser>.
|
||||
/// </summary>
|
||||
internal static string StoreNotIUserSecurityStampStore
|
||||
{
|
||||
get { return GetString("StoreNotIUserSecurityStampStore"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Store does not implement IUserSecurityStampStore<TUser>.
|
||||
/// </summary>
|
||||
internal static string FormatStoreNotIUserSecurityStampStore()
|
||||
{
|
||||
return GetString("StoreNotIUserSecurityStampStore");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Store does not implement IUserAuthenticatorKeyStore<User>.
|
||||
/// </summary>
|
||||
internal static string StoreNotIUserAuthenticatorKeyStore
|
||||
{
|
||||
get { return GetString("StoreNotIUserAuthenticatorKeyStore"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Store does not implement IUserAuthenticatorKeyStore<User>.
|
||||
/// </summary>
|
||||
internal static string FormatStoreNotIUserAuthenticatorKeyStore()
|
||||
{
|
||||
return GetString("StoreNotIUserAuthenticatorKeyStore");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Store does not implement IUserTwoFactorStore<TUser>.
|
||||
/// </summary>
|
||||
internal static string StoreNotIUserTwoFactorStore
|
||||
{
|
||||
get { return GetString("StoreNotIUserTwoFactorStore"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Store does not implement IUserTwoFactorStore<TUser>.
|
||||
/// </summary>
|
||||
internal static string FormatStoreNotIUserTwoFactorStore()
|
||||
{
|
||||
return GetString("StoreNotIUserTwoFactorStore");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recovery code redemption failed.
|
||||
/// </summary>
|
||||
internal static string RecoveryCodeRedemptionFailed
|
||||
{
|
||||
get { return GetString("RecoveryCodeRedemptionFailed"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recovery code redemption failed.
|
||||
/// </summary>
|
||||
internal static string FormatRecoveryCodeRedemptionFailed()
|
||||
{
|
||||
return GetString("RecoveryCodeRedemptionFailed");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// User already has a password set.
|
||||
/// </summary>
|
||||
internal static string UserAlreadyHasPassword
|
||||
{
|
||||
get { return GetString("UserAlreadyHasPassword"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// User already has a password set.
|
||||
/// </summary>
|
||||
internal static string FormatUserAlreadyHasPassword()
|
||||
{
|
||||
return GetString("UserAlreadyHasPassword");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// User already in role '{0}'.
|
||||
/// </summary>
|
||||
internal static string UserAlreadyInRole
|
||||
{
|
||||
get { return GetString("UserAlreadyInRole"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// User already in role '{0}'.
|
||||
/// </summary>
|
||||
internal static string FormatUserAlreadyInRole(object p0)
|
||||
{
|
||||
return string.Format(CultureInfo.CurrentCulture, GetString("UserAlreadyInRole"), p0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// User is locked out.
|
||||
/// </summary>
|
||||
internal static string UserLockedOut
|
||||
{
|
||||
get { return GetString("UserLockedOut"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// User is locked out.
|
||||
/// </summary>
|
||||
internal static string FormatUserLockedOut()
|
||||
{
|
||||
return GetString("UserLockedOut");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Lockout is not enabled for this user.
|
||||
/// </summary>
|
||||
internal static string UserLockoutNotEnabled
|
||||
{
|
||||
get { return GetString("UserLockoutNotEnabled"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Lockout is not enabled for this user.
|
||||
/// </summary>
|
||||
internal static string FormatUserLockoutNotEnabled()
|
||||
{
|
||||
return GetString("UserLockoutNotEnabled");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// User {0} does not exist.
|
||||
/// </summary>
|
||||
internal static string UserNameNotFound
|
||||
{
|
||||
get { return GetString("UserNameNotFound"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// User {0} does not exist.
|
||||
/// </summary>
|
||||
internal static string FormatUserNameNotFound(object p0)
|
||||
{
|
||||
return string.Format(CultureInfo.CurrentCulture, GetString("UserNameNotFound"), p0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// User is not in role '{0}'.
|
||||
/// </summary>
|
||||
internal static string UserNotInRole
|
||||
{
|
||||
get { return GetString("UserNotInRole"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// User is not in role '{0}'.
|
||||
/// </summary>
|
||||
internal static string FormatUserNotInRole(object p0)
|
||||
{
|
||||
return string.Format(CultureInfo.CurrentCulture, GetString("UserNotInRole"), p0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Store does not implement IUserTwoFactorRecoveryCodeStore<User>.
|
||||
/// </summary>
|
||||
internal static string StoreNotIUserTwoFactorRecoveryCodeStore
|
||||
{
|
||||
get { return GetString("StoreNotIUserTwoFactorRecoveryCodeStore"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Store does not implement IUserTwoFactorRecoveryCodeStore<User>.
|
||||
/// </summary>
|
||||
internal static string FormatStoreNotIUserTwoFactorRecoveryCodeStore()
|
||||
{
|
||||
return GetString("StoreNotIUserTwoFactorRecoveryCodeStore");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Passwords must use at least {0} different characters.
|
||||
/// </summary>
|
||||
internal static string PasswordRequiresUniqueChars
|
||||
{
|
||||
get { return GetString("PasswordRequiresUniqueChars"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Passwords must use at least {0} different characters.
|
||||
/// </summary>
|
||||
internal static string FormatPasswordRequiresUniqueChars(object p0)
|
||||
{
|
||||
return string.Format(CultureInfo.CurrentCulture, GetString("PasswordRequiresUniqueChars"), p0);
|
||||
}
|
||||
|
||||
private static string GetString(string name, params string[] formatterNames)
|
||||
{
|
||||
var value = _resourceManager.GetString(name);
|
||||
|
|
|
|||
|
|
@ -117,30 +117,6 @@
|
|||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="ConcurrencyFailure" xml:space="preserve">
|
||||
<value>Optimistic concurrency failure, object has been modified.</value>
|
||||
<comment>Error when optimistic concurrency fails</comment>
|
||||
</data>
|
||||
<data name="DefaultError" xml:space="preserve">
|
||||
<value>An unknown failure has occurred.</value>
|
||||
<comment>Default identity result error message</comment>
|
||||
</data>
|
||||
<data name="DuplicateEmail" xml:space="preserve">
|
||||
<value>Email '{0}' is already taken.</value>
|
||||
<comment>Error for duplicate emails</comment>
|
||||
</data>
|
||||
<data name="DuplicateRoleName" xml:space="preserve">
|
||||
<value>Role name '{0}' is already taken.</value>
|
||||
<comment>Error for duplicate roles</comment>
|
||||
</data>
|
||||
<data name="DuplicateUserName" xml:space="preserve">
|
||||
<value>User name '{0}' is already taken.</value>
|
||||
<comment>Error for duplicate user names</comment>
|
||||
</data>
|
||||
<data name="InvalidEmail" xml:space="preserve">
|
||||
<value>Email '{0}' is invalid.</value>
|
||||
<comment>Invalid email</comment>
|
||||
</data>
|
||||
<data name="InvalidManagerType" xml:space="preserve">
|
||||
<value>Type {0} must derive from {1}<{2}>.</value>
|
||||
<comment>Error when the manager type is not derived correctly</comment>
|
||||
|
|
@ -153,156 +129,4 @@
|
|||
<value>The iteration count must be a positive integer.</value>
|
||||
<comment>Error when the iteration count is < 1.</comment>
|
||||
</data>
|
||||
<data name="InvalidRoleName" xml:space="preserve">
|
||||
<value>Role name '{0}' is invalid.</value>
|
||||
<comment>Error for invalid role names</comment>
|
||||
</data>
|
||||
<data name="InvalidToken" xml:space="preserve">
|
||||
<value>Invalid token.</value>
|
||||
<comment>Error when a token is not recognized</comment>
|
||||
</data>
|
||||
<data name="InvalidUserName" xml:space="preserve">
|
||||
<value>User name '{0}' is invalid, can only contain letters or digits.</value>
|
||||
<comment>User names can only contain letters or digits</comment>
|
||||
</data>
|
||||
<data name="LoginAlreadyAssociated" xml:space="preserve">
|
||||
<value>A user with this login already exists.</value>
|
||||
<comment>Error when a login already linked</comment>
|
||||
</data>
|
||||
<data name="MustCallAddIdentity" xml:space="preserve">
|
||||
<value>AddIdentity must be called on the service collection.</value>
|
||||
<comment>Error when AddIdentity is not called</comment>
|
||||
</data>
|
||||
<data name="NoTokenProvider" xml:space="preserve">
|
||||
<value>No IUserTokenProvider named '{0}' is registered.</value>
|
||||
<comment>Error when there is no IUserTokenProvider</comment>
|
||||
</data>
|
||||
<data name="NullSecurityStamp" xml:space="preserve">
|
||||
<value>User security stamp cannot be null.</value>
|
||||
<comment>Error when a user's security stamp is null.</comment>
|
||||
</data>
|
||||
<data name="PasswordMismatch" xml:space="preserve">
|
||||
<value>Incorrect password.</value>
|
||||
<comment>Error when a password doesn't match</comment>
|
||||
</data>
|
||||
<data name="PasswordRequiresDigit" xml:space="preserve">
|
||||
<value>Passwords must have at least one digit ('0'-'9').</value>
|
||||
<comment>Error when passwords do not have a digit</comment>
|
||||
</data>
|
||||
<data name="PasswordRequiresLower" xml:space="preserve">
|
||||
<value>Passwords must have at least one lowercase ('a'-'z').</value>
|
||||
<comment>Error when passwords do not have a lowercase letter</comment>
|
||||
</data>
|
||||
<data name="PasswordRequiresNonAlphanumeric" xml:space="preserve">
|
||||
<value>Passwords must have at least one non alphanumeric character.</value>
|
||||
<comment>Error when password does not have enough non alphanumeric characters</comment>
|
||||
</data>
|
||||
<data name="PasswordRequiresUpper" xml:space="preserve">
|
||||
<value>Passwords must have at least one uppercase ('A'-'Z').</value>
|
||||
<comment>Error when passwords do not have an uppercase letter</comment>
|
||||
</data>
|
||||
<data name="PasswordTooShort" xml:space="preserve">
|
||||
<value>Passwords must be at least {0} characters.</value>
|
||||
<comment>Error message for passwords that are too short</comment>
|
||||
</data>
|
||||
<data name="RoleNotFound" xml:space="preserve">
|
||||
<value>Role {0} does not exist.</value>
|
||||
<comment>Error when a role does not exist</comment>
|
||||
</data>
|
||||
<data name="StoreNotIQueryableRoleStore" xml:space="preserve">
|
||||
<value>Store does not implement IQueryableRoleStore<TRole>.</value>
|
||||
<comment>Error when the store does not implement this interface</comment>
|
||||
</data>
|
||||
<data name="StoreNotIQueryableUserStore" xml:space="preserve">
|
||||
<value>Store does not implement IQueryableUserStore<TUser>.</value>
|
||||
<comment>Error when the store does not implement this interface</comment>
|
||||
</data>
|
||||
<data name="StoreNotIRoleClaimStore" xml:space="preserve">
|
||||
<value>Store does not implement IRoleClaimStore<TRole>.</value>
|
||||
<comment>Error when the store does not implement this interface</comment>
|
||||
</data>
|
||||
<data name="StoreNotIUserAuthenticationTokenStore" xml:space="preserve">
|
||||
<value>Store does not implement IUserAuthenticationTokenStore<User>.</value>
|
||||
<comment>Error when the store does not implement this interface</comment>
|
||||
</data>
|
||||
<data name="StoreNotIUserClaimStore" xml:space="preserve">
|
||||
<value>Store does not implement IUserClaimStore<TUser>.</value>
|
||||
<comment>Error when the store does not implement this interface</comment>
|
||||
</data>
|
||||
<data name="StoreNotIUserConfirmationStore" xml:space="preserve">
|
||||
<value>Store does not implement IUserConfirmationStore<TUser>.</value>
|
||||
<comment>Error when the store does not implement this interface</comment>
|
||||
</data>
|
||||
<data name="StoreNotIUserEmailStore" xml:space="preserve">
|
||||
<value>Store does not implement IUserEmailStore<TUser>.</value>
|
||||
<comment>Error when the store does not implement this interface</comment>
|
||||
</data>
|
||||
<data name="StoreNotIUserLockoutStore" xml:space="preserve">
|
||||
<value>Store does not implement IUserLockoutStore<TUser>.</value>
|
||||
<comment>Error when the store does not implement this interface</comment>
|
||||
</data>
|
||||
<data name="StoreNotIUserLoginStore" xml:space="preserve">
|
||||
<value>Store does not implement IUserLoginStore<TUser>.</value>
|
||||
<comment>Error when the store does not implement this interface</comment>
|
||||
</data>
|
||||
<data name="StoreNotIUserPasswordStore" xml:space="preserve">
|
||||
<value>Store does not implement IUserPasswordStore<TUser>.</value>
|
||||
<comment>Error when the store does not implement this interface</comment>
|
||||
</data>
|
||||
<data name="StoreNotIUserPhoneNumberStore" xml:space="preserve">
|
||||
<value>Store does not implement IUserPhoneNumberStore<TUser>.</value>
|
||||
<comment>Error when the store does not implement this interface</comment>
|
||||
</data>
|
||||
<data name="StoreNotIUserRoleStore" xml:space="preserve">
|
||||
<value>Store does not implement IUserRoleStore<TUser>.</value>
|
||||
<comment>Error when the store does not implement this interface</comment>
|
||||
</data>
|
||||
<data name="StoreNotIUserSecurityStampStore" xml:space="preserve">
|
||||
<value>Store does not implement IUserSecurityStampStore<TUser>.</value>
|
||||
<comment>Error when the store does not implement this interface</comment>
|
||||
</data>
|
||||
<data name="StoreNotIUserAuthenticatorKeyStore" xml:space="preserve">
|
||||
<value>Store does not implement IUserAuthenticatorKeyStore<User>.</value>
|
||||
<comment>Error when the store does not implement this interface</comment>
|
||||
</data>
|
||||
<data name="StoreNotIUserTwoFactorStore" xml:space="preserve">
|
||||
<value>Store does not implement IUserTwoFactorStore<TUser>.</value>
|
||||
<comment>Error when the store does not implement this interface</comment>
|
||||
</data>
|
||||
<data name="RecoveryCodeRedemptionFailed" xml:space="preserve">
|
||||
<value>Recovery code redemption failed.</value>
|
||||
<comment>Error when a recovery code is not redeemed.</comment>
|
||||
</data>
|
||||
<data name="UserAlreadyHasPassword" xml:space="preserve">
|
||||
<value>User already has a password set.</value>
|
||||
<comment>Error when AddPasswordAsync called when a user already has a password</comment>
|
||||
</data>
|
||||
<data name="UserAlreadyInRole" xml:space="preserve">
|
||||
<value>User already in role '{0}'.</value>
|
||||
<comment>Error when a user is already in a role</comment>
|
||||
</data>
|
||||
<data name="UserLockedOut" xml:space="preserve">
|
||||
<value>User is locked out.</value>
|
||||
<comment>Error when a user is locked out</comment>
|
||||
</data>
|
||||
<data name="UserLockoutNotEnabled" xml:space="preserve">
|
||||
<value>Lockout is not enabled for this user.</value>
|
||||
<comment>Error when lockout is not enabled</comment>
|
||||
</data>
|
||||
<data name="UserNameNotFound" xml:space="preserve">
|
||||
<value>User {0} does not exist.</value>
|
||||
<comment>Error when a user does not exist</comment>
|
||||
</data>
|
||||
<data name="UserNotInRole" xml:space="preserve">
|
||||
<value>User is not in role '{0}'.</value>
|
||||
<comment>Error when a user is not in the role</comment>
|
||||
</data>
|
||||
<data name="StoreNotIUserTwoFactorRecoveryCodeStore" xml:space="preserve">
|
||||
<value>Store does not implement IUserTwoFactorRecoveryCodeStore<User>.</value>
|
||||
<comment>Error when the store does not implement this interface</comment>
|
||||
</data>
|
||||
<data name="PasswordRequiresUniqueChars" xml:space="preserve">
|
||||
<value>Passwords must use at least {0} different characters.</value>
|
||||
<comment>Error message for passwords that are based on similar characters</comment>
|
||||
</data>
|
||||
</root>
|
||||
|
|
@ -18,7 +18,7 @@ namespace Microsoft.AspNetCore.Identity
|
|||
public class SecurityStampValidator<TUser> : ISecurityStampValidator where TUser : class
|
||||
{
|
||||
private readonly SignInManager<TUser> _signInManager;
|
||||
private readonly IdentityOptions _options;
|
||||
private readonly SecurityStampValidatorOptions _options;
|
||||
private ISystemClock _clock;
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -27,7 +27,7 @@ namespace Microsoft.AspNetCore.Identity
|
|||
/// <param name="options">Used to access the <see cref="IdentityOptions"/>.</param>
|
||||
/// <param name="signInManager">The <see cref="SignInManager{TUser}"/>.</param>
|
||||
/// <param name="clock">The system clock.</param>
|
||||
public SecurityStampValidator(IOptions<IdentityOptions> options, SignInManager<TUser> signInManager, ISystemClock clock)
|
||||
public SecurityStampValidator(IOptions<SecurityStampValidatorOptions> options, SignInManager<TUser> signInManager, ISystemClock clock)
|
||||
{
|
||||
if (options == null)
|
||||
{
|
||||
|
|
@ -63,7 +63,7 @@ namespace Microsoft.AspNetCore.Identity
|
|||
if (issuedUtc != null)
|
||||
{
|
||||
var timeElapsed = currentUtc.Subtract(issuedUtc.Value);
|
||||
validate = timeElapsed > _options.SecurityStampValidationInterval;
|
||||
validate = timeElapsed > _options.ValidationInterval;
|
||||
}
|
||||
if (validate)
|
||||
{
|
||||
|
|
@ -72,7 +72,7 @@ namespace Microsoft.AspNetCore.Identity
|
|||
{
|
||||
var newPrincipal = await _signInManager.CreateUserPrincipalAsync(user);
|
||||
|
||||
if (_options.OnSecurityStampRefreshingPrincipal != null)
|
||||
if (_options.OnRefreshingPrincipal != null)
|
||||
{
|
||||
var replaceContext = new SecurityStampRefreshingPrincipalContext
|
||||
{
|
||||
|
|
@ -81,7 +81,7 @@ namespace Microsoft.AspNetCore.Identity
|
|||
};
|
||||
|
||||
// Note: a null principal is allowed and results in a failed authentication.
|
||||
await _options.OnSecurityStampRefreshingPrincipal(replaceContext);
|
||||
await _options.OnRefreshingPrincipal(replaceContext);
|
||||
newPrincipal = replaceContext.NewPrincipal;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,27 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Microsoft.AspNetCore.Identity
|
||||
{
|
||||
/// <summary>
|
||||
/// Options for <see cref="ISecurityStampValidator"/>.
|
||||
/// </summary>
|
||||
public class SecurityStampValidatorOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the <see cref="TimeSpan"/> after which security stamps are re-validated.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The <see cref="TimeSpan"/> after which security stamps are re-validated.
|
||||
/// </value>
|
||||
public TimeSpan ValidationInterval { get; set; } = TimeSpan.FromMinutes(30);
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when the default security stamp validator replaces the user's ClaimsPrincipal in the cookie.
|
||||
/// </summary>
|
||||
public Func<SecurityStampRefreshingPrincipalContext, Task> OnRefreshingPrincipal { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -126,7 +126,7 @@ namespace Microsoft.AspNetCore.Identity
|
|||
throw new ArgumentNullException(nameof(principal));
|
||||
}
|
||||
return principal?.Identities != null &&
|
||||
principal.Identities.Any(i => i.AuthenticationType == Options.Cookies.ApplicationCookieAuthenticationScheme);
|
||||
principal.Identities.Any(i => i.AuthenticationType == IdentityConstants.ApplicationScheme);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -161,7 +161,7 @@ namespace Microsoft.AspNetCore.Identity
|
|||
/// <returns>The task object representing the asynchronous operation.</returns>
|
||||
public virtual async Task RefreshSignInAsync(TUser user)
|
||||
{
|
||||
var auth = await Context.AuthenticateAsync(Options.Cookies.ApplicationCookieAuthenticationScheme);
|
||||
var auth = await Context.AuthenticateAsync(IdentityConstants.ApplicationScheme);
|
||||
var authenticationMethod = auth?.Principal?.FindFirstValue(ClaimTypes.AuthenticationMethod);
|
||||
await SignInAsync(user, auth?.Properties, authenticationMethod);
|
||||
}
|
||||
|
|
@ -193,7 +193,7 @@ namespace Microsoft.AspNetCore.Identity
|
|||
{
|
||||
userPrincipal.Identities.First().AddClaim(new Claim(ClaimTypes.AuthenticationMethod, authenticationMethod));
|
||||
}
|
||||
await Context.SignInAsync(Options.Cookies.ApplicationCookieAuthenticationScheme,
|
||||
await Context.SignInAsync(IdentityConstants.ApplicationScheme,
|
||||
userPrincipal,
|
||||
authenticationProperties ?? new AuthenticationProperties());
|
||||
}
|
||||
|
|
@ -203,9 +203,9 @@ namespace Microsoft.AspNetCore.Identity
|
|||
/// </summary>
|
||||
public virtual async Task SignOutAsync()
|
||||
{
|
||||
await Context.SignOutAsync(Options.Cookies.ApplicationCookieAuthenticationScheme);
|
||||
await Context.SignOutAsync(Options.Cookies.ExternalCookieAuthenticationScheme);
|
||||
await Context.SignOutAsync(Options.Cookies.TwoFactorUserIdCookieAuthenticationScheme);
|
||||
await Context.SignOutAsync(IdentityConstants.ApplicationScheme);
|
||||
await Context.SignOutAsync(IdentityConstants.ExternalScheme);
|
||||
await Context.SignOutAsync(IdentityConstants.TwoFactorUserIdScheme);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -333,7 +333,7 @@ namespace Microsoft.AspNetCore.Identity
|
|||
public virtual async Task<bool> IsTwoFactorClientRememberedAsync(TUser user)
|
||||
{
|
||||
var userId = await UserManager.GetUserIdAsync(user);
|
||||
var result = await Context.AuthenticateAsync(Options.Cookies.TwoFactorRememberMeCookieAuthenticationScheme);
|
||||
var result = await Context.AuthenticateAsync(IdentityConstants.TwoFactorRememberMeScheme);
|
||||
return (result?.Principal != null && result.Principal.FindFirstValue(ClaimTypes.Name) == userId);
|
||||
}
|
||||
|
||||
|
|
@ -346,9 +346,9 @@ namespace Microsoft.AspNetCore.Identity
|
|||
public virtual async Task RememberTwoFactorClientAsync(TUser user)
|
||||
{
|
||||
var userId = await UserManager.GetUserIdAsync(user);
|
||||
var rememberBrowserIdentity = new ClaimsIdentity(Options.Cookies.TwoFactorRememberMeCookieAuthenticationScheme);
|
||||
var rememberBrowserIdentity = new ClaimsIdentity(IdentityConstants.TwoFactorRememberMeScheme);
|
||||
rememberBrowserIdentity.AddClaim(new Claim(ClaimTypes.Name, userId));
|
||||
await Context.SignInAsync(Options.Cookies.TwoFactorRememberMeCookieAuthenticationScheme,
|
||||
await Context.SignInAsync(IdentityConstants.TwoFactorRememberMeScheme,
|
||||
new ClaimsPrincipal(rememberBrowserIdentity),
|
||||
new AuthenticationProperties { IsPersistent = true });
|
||||
}
|
||||
|
|
@ -359,7 +359,7 @@ namespace Microsoft.AspNetCore.Identity
|
|||
/// <returns>The task object representing the asynchronous operation.</returns>
|
||||
public virtual Task ForgetTwoFactorClientAsync()
|
||||
{
|
||||
return Context.SignOutAsync(Options.Cookies.TwoFactorRememberMeCookieAuthenticationScheme);
|
||||
return Context.SignOutAsync(IdentityConstants.TwoFactorRememberMeScheme);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -399,10 +399,10 @@ namespace Microsoft.AspNetCore.Identity
|
|||
// Cleanup external cookie
|
||||
if (twoFactorInfo.LoginProvider != null)
|
||||
{
|
||||
await Context.SignOutAsync(Options.Cookies.ExternalCookieAuthenticationScheme);
|
||||
await Context.SignOutAsync(IdentityConstants.ExternalScheme);
|
||||
}
|
||||
// Cleanup two factor user id cookie
|
||||
await Context.SignOutAsync(Options.Cookies.TwoFactorUserIdCookieAuthenticationScheme);
|
||||
await Context.SignOutAsync(IdentityConstants.TwoFactorUserIdScheme);
|
||||
if (rememberClient)
|
||||
{
|
||||
await RememberTwoFactorClientAsync(user);
|
||||
|
|
@ -556,7 +556,7 @@ namespace Microsoft.AspNetCore.Identity
|
|||
/// for the sign-in attempt.</returns>
|
||||
public virtual async Task<ExternalLoginInfo> GetExternalLoginInfoAsync(string expectedXsrf = null)
|
||||
{
|
||||
var auth = await Context.AuthenticateAsync(Options.Cookies.ExternalCookieAuthenticationScheme);
|
||||
var auth = await Context.AuthenticateAsync(IdentityConstants.ExternalScheme);
|
||||
var items = auth?.Properties?.Items;
|
||||
if (auth?.Principal == null || items == null || !items.ContainsKey(LoginProviderKey))
|
||||
{
|
||||
|
|
@ -648,7 +648,7 @@ namespace Microsoft.AspNetCore.Identity
|
|||
/// <returns>A <see cref="ClaimsPrincipal"/> containing the user 2fa information.</returns>
|
||||
internal ClaimsPrincipal StoreTwoFactorInfo(string userId, string loginProvider)
|
||||
{
|
||||
var identity = new ClaimsIdentity(Options.Cookies.TwoFactorUserIdCookieAuthenticationScheme);
|
||||
var identity = new ClaimsIdentity(IdentityConstants.TwoFactorUserIdScheme);
|
||||
identity.AddClaim(new Claim(ClaimTypes.Name, userId));
|
||||
if (loginProvider != null)
|
||||
{
|
||||
|
|
@ -663,7 +663,7 @@ namespace Microsoft.AspNetCore.Identity
|
|||
{
|
||||
return null;
|
||||
}
|
||||
var identity = new ClaimsIdentity(Options.Cookies.TwoFactorUserIdCookieAuthenticationScheme);
|
||||
var identity = new ClaimsIdentity(IdentityConstants.TwoFactorUserIdScheme);
|
||||
identity.AddClaim(new Claim(ClaimTypes.Name, info.UserId));
|
||||
if (info.LoginProvider != null)
|
||||
{
|
||||
|
|
@ -683,14 +683,14 @@ namespace Microsoft.AspNetCore.Identity
|
|||
{
|
||||
// Store the userId for use after two factor check
|
||||
var userId = await UserManager.GetUserIdAsync(user);
|
||||
await Context.SignInAsync(Options.Cookies.TwoFactorUserIdCookieAuthenticationScheme, StoreTwoFactorInfo(userId, loginProvider));
|
||||
await Context.SignInAsync(IdentityConstants.TwoFactorUserIdScheme, StoreTwoFactorInfo(userId, loginProvider));
|
||||
return SignInResult.TwoFactorRequired;
|
||||
}
|
||||
}
|
||||
// Cleanup external cookie
|
||||
if (loginProvider != null)
|
||||
{
|
||||
await Context.SignOutAsync(Options.Cookies.ExternalCookieAuthenticationScheme);
|
||||
await Context.SignOutAsync(IdentityConstants.ExternalScheme);
|
||||
}
|
||||
await SignInAsync(user, isPersistent, loginProvider);
|
||||
return SignInResult.Success;
|
||||
|
|
@ -698,7 +698,7 @@ namespace Microsoft.AspNetCore.Identity
|
|||
|
||||
private async Task<TwoFactorAuthenticationInfo> RetrieveTwoFactorInfoAsync()
|
||||
{
|
||||
var result = await Context.AuthenticateAsync(Options.Cookies.TwoFactorUserIdCookieAuthenticationScheme);
|
||||
var result = await Context.AuthenticateAsync(IdentityConstants.TwoFactorUserIdScheme);
|
||||
if (result?.Principal != null)
|
||||
{
|
||||
return new TwoFactorAuthenticationInfo
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
using System;
|
||||
using System.Globalization;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Microsoft.AspNetCore.Identity
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
|
||||
namespace Microsoft.AspNetCore.Identity
|
||||
{
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ namespace Microsoft.AspNetCore.Identity
|
|||
}
|
||||
var userId = await UserManager.GetUserIdAsync(user);
|
||||
var userName = await UserManager.GetUserNameAsync(user);
|
||||
var id = new ClaimsIdentity(Options.Cookies.ApplicationCookieAuthenticationScheme,
|
||||
var id = new ClaimsIdentity(IdentityConstants.ApplicationScheme,
|
||||
Options.ClaimsIdentity.UserNameClaimType,
|
||||
Options.ClaimsIdentity.RoleClaimType);
|
||||
id.AddClaim(new Claim(Options.ClaimsIdentity.UserIdClaimType, userId));
|
||||
|
|
|
|||
|
|
@ -0,0 +1,119 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace Microsoft.AspNetCore.Identity
|
||||
{
|
||||
// See http://tools.ietf.org/html/rfc3548#section-5
|
||||
internal static class Base32
|
||||
{
|
||||
private static readonly string _base32Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
|
||||
|
||||
public static string ToBase32(byte[] input)
|
||||
{
|
||||
if (input == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(input));
|
||||
}
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int offset = 0; offset < input.Length;)
|
||||
{
|
||||
byte a, b, c, d, e, f, g, h;
|
||||
int numCharsToOutput = GetNextGroup(input, ref offset, out a, out b, out c, out d, out e, out f, out g, out h);
|
||||
|
||||
sb.Append((numCharsToOutput >= 1) ? _base32Chars[a] : '=');
|
||||
sb.Append((numCharsToOutput >= 2) ? _base32Chars[b] : '=');
|
||||
sb.Append((numCharsToOutput >= 3) ? _base32Chars[c] : '=');
|
||||
sb.Append((numCharsToOutput >= 4) ? _base32Chars[d] : '=');
|
||||
sb.Append((numCharsToOutput >= 5) ? _base32Chars[e] : '=');
|
||||
sb.Append((numCharsToOutput >= 6) ? _base32Chars[f] : '=');
|
||||
sb.Append((numCharsToOutput >= 7) ? _base32Chars[g] : '=');
|
||||
sb.Append((numCharsToOutput >= 8) ? _base32Chars[h] : '=');
|
||||
}
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public static byte[] FromBase32(string input)
|
||||
{
|
||||
if (input == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(input));
|
||||
}
|
||||
input = input.TrimEnd('=').ToUpperInvariant();
|
||||
if (input.Length == 0)
|
||||
{
|
||||
return new byte[0];
|
||||
}
|
||||
|
||||
var output = new byte[input.Length * 5 / 8];
|
||||
var bitIndex = 0;
|
||||
var inputIndex = 0;
|
||||
var outputBits = 0;
|
||||
var outputIndex = 0;
|
||||
while (outputIndex < output.Length)
|
||||
{
|
||||
var byteIndex = _base32Chars.IndexOf(input[inputIndex]);
|
||||
if (byteIndex < 0)
|
||||
{
|
||||
throw new FormatException();
|
||||
}
|
||||
|
||||
var bits = Math.Min(5 - bitIndex, 8 - outputBits);
|
||||
output[outputIndex] <<= bits;
|
||||
output[outputIndex] |= (byte)(byteIndex >> (5 - (bitIndex + bits)));
|
||||
|
||||
bitIndex += bits;
|
||||
if (bitIndex >= 5)
|
||||
{
|
||||
inputIndex++;
|
||||
bitIndex = 0;
|
||||
}
|
||||
|
||||
outputBits += bits;
|
||||
if (outputBits >= 8)
|
||||
{
|
||||
outputIndex++;
|
||||
outputBits = 0;
|
||||
}
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
// returns the number of bytes that were output
|
||||
private static int GetNextGroup(byte[] input, ref int offset, out byte a, out byte b, out byte c, out byte d, out byte e, out byte f, out byte g, out byte h)
|
||||
{
|
||||
uint b1, b2, b3, b4, b5;
|
||||
|
||||
int retVal;
|
||||
switch (offset - input.Length)
|
||||
{
|
||||
case 1: retVal = 2; break;
|
||||
case 2: retVal = 4; break;
|
||||
case 3: retVal = 5; break;
|
||||
case 4: retVal = 7; break;
|
||||
default: retVal = 8; break;
|
||||
}
|
||||
|
||||
b1 = (offset < input.Length) ? input[offset++] : 0U;
|
||||
b2 = (offset < input.Length) ? input[offset++] : 0U;
|
||||
b3 = (offset < input.Length) ? input[offset++] : 0U;
|
||||
b4 = (offset < input.Length) ? input[offset++] : 0U;
|
||||
b5 = (offset < input.Length) ? input[offset++] : 0U;
|
||||
|
||||
a = (byte)(b1 >> 3);
|
||||
b = (byte)(((b1 & 0x07) << 2) | (b2 >> 6));
|
||||
c = (byte)((b2 >> 1) & 0x1f);
|
||||
d = (byte)(((b2 & 0x01) << 4) | (b3 >> 4));
|
||||
e = (byte)(((b3 & 0x0f) << 1) | (b4 >> 7));
|
||||
f = (byte)((b4 >> 2) & 0x1f);
|
||||
g = (byte)(((b4 & 0x3) << 3) | (b5 >> 5));
|
||||
h = (byte)(b5 & 0x1f);
|
||||
|
||||
return retVal;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,6 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
|
||||
namespace Microsoft.AspNetCore.Builder
|
||||
|
|
@ -52,14 +50,6 @@ namespace Microsoft.AspNetCore.Builder
|
|||
/// </value>
|
||||
public SignInOptions SignIn { get; set; } = new SignInOptions();
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the <see cref="IdentityCookieOptions"/> for the identity system.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The <see cref="IdentityCookieOptions"/> for the identity system.
|
||||
/// </value>
|
||||
public IdentityCookieOptions Cookies { get; set; } = new IdentityCookieOptions();
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the <see cref="TokenOptions"/> for the identity system.
|
||||
/// </summary>
|
||||
|
|
@ -67,18 +57,5 @@ namespace Microsoft.AspNetCore.Builder
|
|||
/// The <see cref="TokenOptions"/> for the identity system.
|
||||
/// </value>
|
||||
public TokenOptions Tokens { get; set; } = new TokenOptions();
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the <see cref="TimeSpan"/> after which security stamps are re-validated.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The <see cref="TimeSpan"/> after which security stamps are re-validated.
|
||||
/// </value>
|
||||
public TimeSpan SecurityStampValidationInterval { get; set; } = TimeSpan.FromMinutes(30);
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when the default security stamp validator replaces the user's ClaimsPrincipal in the cookie.
|
||||
/// </summary>
|
||||
public Func<SecurityStampRefreshingPrincipalContext, Task> OnSecurityStampRefreshingPrincipal { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<Import Project="..\..\build\common.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<Description>ASP.NET Core Identity is the membership system for building ASP.NET Core web applications, including membership, login, and user data. ASP.NET Core Identity allows you to add login features to your application and makes it easy to customize data about the logged in user.</Description>
|
||||
<TargetFramework>netstandard1.3</TargetFramework>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<PackageTags>aspnetcore;identity;membership</PackageTags>
|
||||
<EnableApiCheck>false</EnableApiCheck>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="$(AspNetCoreVersion)" />
|
||||
<PackageReference Include="Microsoft.Extensions.Options" Version="$(AspNetCoreVersion)" />
|
||||
<PackageReference Include="Microsoft.Extensions.TaskCache.Sources" Version="$(AspNetCoreVersion)" PrivateAssets="All" />
|
||||
<PackageReference Include="System.ComponentModel.Annotations" Version="$(CoreFxVersion)" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.3' ">
|
||||
<PackageReference Include="System.Security.Claims" Version="$(CoreFxVersion)" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Identity.Specification.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
|
||||
[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Identity.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
|
||||
[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Identity.EntityFrameworkCore.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
|
||||
[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Identity.EntityFrameworkCore.InMemory.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
|
||||
[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Identity.InMemory.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
|
||||
|
|
@ -0,0 +1,782 @@
|
|||
// <auto-generated />
|
||||
namespace Microsoft.AspNetCore.Identity
|
||||
{
|
||||
using System.Globalization;
|
||||
using System.Reflection;
|
||||
using System.Resources;
|
||||
|
||||
internal static class Resources
|
||||
{
|
||||
private static readonly ResourceManager _resourceManager
|
||||
= new ResourceManager("Microsoft.Extensions.Identity.Core.Resources", typeof(Resources).GetTypeInfo().Assembly);
|
||||
|
||||
/// <summary>
|
||||
/// Optimistic concurrency failure, object has been modified.
|
||||
/// </summary>
|
||||
internal static string ConcurrencyFailure
|
||||
{
|
||||
get { return GetString("ConcurrencyFailure"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Optimistic concurrency failure, object has been modified.
|
||||
/// </summary>
|
||||
internal static string FormatConcurrencyFailure()
|
||||
{
|
||||
return GetString("ConcurrencyFailure");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An unknown failure has occurred.
|
||||
/// </summary>
|
||||
internal static string DefaultError
|
||||
{
|
||||
get { return GetString("DefaultError"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An unknown failure has occurred.
|
||||
/// </summary>
|
||||
internal static string FormatDefaultError()
|
||||
{
|
||||
return GetString("DefaultError");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Email '{0}' is already taken.
|
||||
/// </summary>
|
||||
internal static string DuplicateEmail
|
||||
{
|
||||
get { return GetString("DuplicateEmail"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Email '{0}' is already taken.
|
||||
/// </summary>
|
||||
internal static string FormatDuplicateEmail(object p0)
|
||||
{
|
||||
return string.Format(CultureInfo.CurrentCulture, GetString("DuplicateEmail"), p0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Role name '{0}' is already taken.
|
||||
/// </summary>
|
||||
internal static string DuplicateRoleName
|
||||
{
|
||||
get { return GetString("DuplicateRoleName"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Role name '{0}' is already taken.
|
||||
/// </summary>
|
||||
internal static string FormatDuplicateRoleName(object p0)
|
||||
{
|
||||
return string.Format(CultureInfo.CurrentCulture, GetString("DuplicateRoleName"), p0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// User name '{0}' is already taken.
|
||||
/// </summary>
|
||||
internal static string DuplicateUserName
|
||||
{
|
||||
get { return GetString("DuplicateUserName"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// User name '{0}' is already taken.
|
||||
/// </summary>
|
||||
internal static string FormatDuplicateUserName(object p0)
|
||||
{
|
||||
return string.Format(CultureInfo.CurrentCulture, GetString("DuplicateUserName"), p0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Email '{0}' is invalid.
|
||||
/// </summary>
|
||||
internal static string InvalidEmail
|
||||
{
|
||||
get { return GetString("InvalidEmail"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Email '{0}' is invalid.
|
||||
/// </summary>
|
||||
internal static string FormatInvalidEmail(object p0)
|
||||
{
|
||||
return string.Format(CultureInfo.CurrentCulture, GetString("InvalidEmail"), p0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Type {0} must derive from {1}<{2}>.
|
||||
/// </summary>
|
||||
internal static string InvalidManagerType
|
||||
{
|
||||
get { return GetString("InvalidManagerType"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Type {0} must derive from {1}<{2}>.
|
||||
/// </summary>
|
||||
internal static string FormatInvalidManagerType(object p0, object p1, object p2)
|
||||
{
|
||||
return string.Format(CultureInfo.CurrentCulture, GetString("InvalidManagerType"), p0, p1, p2);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The provided PasswordHasherCompatibilityMode is invalid.
|
||||
/// </summary>
|
||||
internal static string InvalidPasswordHasherCompatibilityMode
|
||||
{
|
||||
get { return GetString("InvalidPasswordHasherCompatibilityMode"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The provided PasswordHasherCompatibilityMode is invalid.
|
||||
/// </summary>
|
||||
internal static string FormatInvalidPasswordHasherCompatibilityMode()
|
||||
{
|
||||
return GetString("InvalidPasswordHasherCompatibilityMode");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The iteration count must be a positive integer.
|
||||
/// </summary>
|
||||
internal static string InvalidPasswordHasherIterationCount
|
||||
{
|
||||
get { return GetString("InvalidPasswordHasherIterationCount"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The iteration count must be a positive integer.
|
||||
/// </summary>
|
||||
internal static string FormatInvalidPasswordHasherIterationCount()
|
||||
{
|
||||
return GetString("InvalidPasswordHasherIterationCount");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Role name '{0}' is invalid.
|
||||
/// </summary>
|
||||
internal static string InvalidRoleName
|
||||
{
|
||||
get { return GetString("InvalidRoleName"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Role name '{0}' is invalid.
|
||||
/// </summary>
|
||||
internal static string FormatInvalidRoleName(object p0)
|
||||
{
|
||||
return string.Format(CultureInfo.CurrentCulture, GetString("InvalidRoleName"), p0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invalid token.
|
||||
/// </summary>
|
||||
internal static string InvalidToken
|
||||
{
|
||||
get { return GetString("InvalidToken"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invalid token.
|
||||
/// </summary>
|
||||
internal static string FormatInvalidToken()
|
||||
{
|
||||
return GetString("InvalidToken");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// User name '{0}' is invalid, can only contain letters or digits.
|
||||
/// </summary>
|
||||
internal static string InvalidUserName
|
||||
{
|
||||
get { return GetString("InvalidUserName"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// User name '{0}' is invalid, can only contain letters or digits.
|
||||
/// </summary>
|
||||
internal static string FormatInvalidUserName(object p0)
|
||||
{
|
||||
return string.Format(CultureInfo.CurrentCulture, GetString("InvalidUserName"), p0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A user with this login already exists.
|
||||
/// </summary>
|
||||
internal static string LoginAlreadyAssociated
|
||||
{
|
||||
get { return GetString("LoginAlreadyAssociated"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A user with this login already exists.
|
||||
/// </summary>
|
||||
internal static string FormatLoginAlreadyAssociated()
|
||||
{
|
||||
return GetString("LoginAlreadyAssociated");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// AddIdentity must be called on the service collection.
|
||||
/// </summary>
|
||||
internal static string MustCallAddIdentity
|
||||
{
|
||||
get { return GetString("MustCallAddIdentity"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// AddIdentity must be called on the service collection.
|
||||
/// </summary>
|
||||
internal static string FormatMustCallAddIdentity()
|
||||
{
|
||||
return GetString("MustCallAddIdentity");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// No IUserTokenProvider named '{0}' is registered.
|
||||
/// </summary>
|
||||
internal static string NoTokenProvider
|
||||
{
|
||||
get { return GetString("NoTokenProvider"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// No IUserTokenProvider named '{0}' is registered.
|
||||
/// </summary>
|
||||
internal static string FormatNoTokenProvider(object p0)
|
||||
{
|
||||
return string.Format(CultureInfo.CurrentCulture, GetString("NoTokenProvider"), p0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// User security stamp cannot be null.
|
||||
/// </summary>
|
||||
internal static string NullSecurityStamp
|
||||
{
|
||||
get { return GetString("NullSecurityStamp"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// User security stamp cannot be null.
|
||||
/// </summary>
|
||||
internal static string FormatNullSecurityStamp()
|
||||
{
|
||||
return GetString("NullSecurityStamp");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Incorrect password.
|
||||
/// </summary>
|
||||
internal static string PasswordMismatch
|
||||
{
|
||||
get { return GetString("PasswordMismatch"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Incorrect password.
|
||||
/// </summary>
|
||||
internal static string FormatPasswordMismatch()
|
||||
{
|
||||
return GetString("PasswordMismatch");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Passwords must have at least one digit ('0'-'9').
|
||||
/// </summary>
|
||||
internal static string PasswordRequiresDigit
|
||||
{
|
||||
get { return GetString("PasswordRequiresDigit"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Passwords must have at least one digit ('0'-'9').
|
||||
/// </summary>
|
||||
internal static string FormatPasswordRequiresDigit()
|
||||
{
|
||||
return GetString("PasswordRequiresDigit");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Passwords must have at least one lowercase ('a'-'z').
|
||||
/// </summary>
|
||||
internal static string PasswordRequiresLower
|
||||
{
|
||||
get { return GetString("PasswordRequiresLower"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Passwords must have at least one lowercase ('a'-'z').
|
||||
/// </summary>
|
||||
internal static string FormatPasswordRequiresLower()
|
||||
{
|
||||
return GetString("PasswordRequiresLower");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Passwords must have at least one non alphanumeric character.
|
||||
/// </summary>
|
||||
internal static string PasswordRequiresNonAlphanumeric
|
||||
{
|
||||
get { return GetString("PasswordRequiresNonAlphanumeric"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Passwords must have at least one non alphanumeric character.
|
||||
/// </summary>
|
||||
internal static string FormatPasswordRequiresNonAlphanumeric()
|
||||
{
|
||||
return GetString("PasswordRequiresNonAlphanumeric");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Passwords must have at least one uppercase ('A'-'Z').
|
||||
/// </summary>
|
||||
internal static string PasswordRequiresUpper
|
||||
{
|
||||
get { return GetString("PasswordRequiresUpper"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Passwords must have at least one uppercase ('A'-'Z').
|
||||
/// </summary>
|
||||
internal static string FormatPasswordRequiresUpper()
|
||||
{
|
||||
return GetString("PasswordRequiresUpper");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Passwords must be at least {0} characters.
|
||||
/// </summary>
|
||||
internal static string PasswordTooShort
|
||||
{
|
||||
get { return GetString("PasswordTooShort"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Passwords must be at least {0} characters.
|
||||
/// </summary>
|
||||
internal static string FormatPasswordTooShort(object p0)
|
||||
{
|
||||
return string.Format(CultureInfo.CurrentCulture, GetString("PasswordTooShort"), p0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Role {0} does not exist.
|
||||
/// </summary>
|
||||
internal static string RoleNotFound
|
||||
{
|
||||
get { return GetString("RoleNotFound"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Role {0} does not exist.
|
||||
/// </summary>
|
||||
internal static string FormatRoleNotFound(object p0)
|
||||
{
|
||||
return string.Format(CultureInfo.CurrentCulture, GetString("RoleNotFound"), p0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Store does not implement IQueryableRoleStore<TRole>.
|
||||
/// </summary>
|
||||
internal static string StoreNotIQueryableRoleStore
|
||||
{
|
||||
get { return GetString("StoreNotIQueryableRoleStore"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Store does not implement IQueryableRoleStore<TRole>.
|
||||
/// </summary>
|
||||
internal static string FormatStoreNotIQueryableRoleStore()
|
||||
{
|
||||
return GetString("StoreNotIQueryableRoleStore");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Store does not implement IQueryableUserStore<TUser>.
|
||||
/// </summary>
|
||||
internal static string StoreNotIQueryableUserStore
|
||||
{
|
||||
get { return GetString("StoreNotIQueryableUserStore"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Store does not implement IQueryableUserStore<TUser>.
|
||||
/// </summary>
|
||||
internal static string FormatStoreNotIQueryableUserStore()
|
||||
{
|
||||
return GetString("StoreNotIQueryableUserStore");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Store does not implement IRoleClaimStore<TRole>.
|
||||
/// </summary>
|
||||
internal static string StoreNotIRoleClaimStore
|
||||
{
|
||||
get { return GetString("StoreNotIRoleClaimStore"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Store does not implement IRoleClaimStore<TRole>.
|
||||
/// </summary>
|
||||
internal static string FormatStoreNotIRoleClaimStore()
|
||||
{
|
||||
return GetString("StoreNotIRoleClaimStore");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Store does not implement IUserAuthenticationTokenStore<User>.
|
||||
/// </summary>
|
||||
internal static string StoreNotIUserAuthenticationTokenStore
|
||||
{
|
||||
get { return GetString("StoreNotIUserAuthenticationTokenStore"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Store does not implement IUserAuthenticationTokenStore<User>.
|
||||
/// </summary>
|
||||
internal static string FormatStoreNotIUserAuthenticationTokenStore()
|
||||
{
|
||||
return GetString("StoreNotIUserAuthenticationTokenStore");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Store does not implement IUserClaimStore<TUser>.
|
||||
/// </summary>
|
||||
internal static string StoreNotIUserClaimStore
|
||||
{
|
||||
get { return GetString("StoreNotIUserClaimStore"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Store does not implement IUserClaimStore<TUser>.
|
||||
/// </summary>
|
||||
internal static string FormatStoreNotIUserClaimStore()
|
||||
{
|
||||
return GetString("StoreNotIUserClaimStore");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Store does not implement IUserConfirmationStore<TUser>.
|
||||
/// </summary>
|
||||
internal static string StoreNotIUserConfirmationStore
|
||||
{
|
||||
get { return GetString("StoreNotIUserConfirmationStore"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Store does not implement IUserConfirmationStore<TUser>.
|
||||
/// </summary>
|
||||
internal static string FormatStoreNotIUserConfirmationStore()
|
||||
{
|
||||
return GetString("StoreNotIUserConfirmationStore");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Store does not implement IUserEmailStore<TUser>.
|
||||
/// </summary>
|
||||
internal static string StoreNotIUserEmailStore
|
||||
{
|
||||
get { return GetString("StoreNotIUserEmailStore"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Store does not implement IUserEmailStore<TUser>.
|
||||
/// </summary>
|
||||
internal static string FormatStoreNotIUserEmailStore()
|
||||
{
|
||||
return GetString("StoreNotIUserEmailStore");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Store does not implement IUserLockoutStore<TUser>.
|
||||
/// </summary>
|
||||
internal static string StoreNotIUserLockoutStore
|
||||
{
|
||||
get { return GetString("StoreNotIUserLockoutStore"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Store does not implement IUserLockoutStore<TUser>.
|
||||
/// </summary>
|
||||
internal static string FormatStoreNotIUserLockoutStore()
|
||||
{
|
||||
return GetString("StoreNotIUserLockoutStore");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Store does not implement IUserLoginStore<TUser>.
|
||||
/// </summary>
|
||||
internal static string StoreNotIUserLoginStore
|
||||
{
|
||||
get { return GetString("StoreNotIUserLoginStore"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Store does not implement IUserLoginStore<TUser>.
|
||||
/// </summary>
|
||||
internal static string FormatStoreNotIUserLoginStore()
|
||||
{
|
||||
return GetString("StoreNotIUserLoginStore");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Store does not implement IUserPasswordStore<TUser>.
|
||||
/// </summary>
|
||||
internal static string StoreNotIUserPasswordStore
|
||||
{
|
||||
get { return GetString("StoreNotIUserPasswordStore"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Store does not implement IUserPasswordStore<TUser>.
|
||||
/// </summary>
|
||||
internal static string FormatStoreNotIUserPasswordStore()
|
||||
{
|
||||
return GetString("StoreNotIUserPasswordStore");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Store does not implement IUserPhoneNumberStore<TUser>.
|
||||
/// </summary>
|
||||
internal static string StoreNotIUserPhoneNumberStore
|
||||
{
|
||||
get { return GetString("StoreNotIUserPhoneNumberStore"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Store does not implement IUserPhoneNumberStore<TUser>.
|
||||
/// </summary>
|
||||
internal static string FormatStoreNotIUserPhoneNumberStore()
|
||||
{
|
||||
return GetString("StoreNotIUserPhoneNumberStore");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Store does not implement IUserRoleStore<TUser>.
|
||||
/// </summary>
|
||||
internal static string StoreNotIUserRoleStore
|
||||
{
|
||||
get { return GetString("StoreNotIUserRoleStore"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Store does not implement IUserRoleStore<TUser>.
|
||||
/// </summary>
|
||||
internal static string FormatStoreNotIUserRoleStore()
|
||||
{
|
||||
return GetString("StoreNotIUserRoleStore");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Store does not implement IUserSecurityStampStore<TUser>.
|
||||
/// </summary>
|
||||
internal static string StoreNotIUserSecurityStampStore
|
||||
{
|
||||
get { return GetString("StoreNotIUserSecurityStampStore"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Store does not implement IUserSecurityStampStore<TUser>.
|
||||
/// </summary>
|
||||
internal static string FormatStoreNotIUserSecurityStampStore()
|
||||
{
|
||||
return GetString("StoreNotIUserSecurityStampStore");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Store does not implement IUserAuthenticatorKeyStore<User>.
|
||||
/// </summary>
|
||||
internal static string StoreNotIUserAuthenticatorKeyStore
|
||||
{
|
||||
get { return GetString("StoreNotIUserAuthenticatorKeyStore"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Store does not implement IUserAuthenticatorKeyStore<User>.
|
||||
/// </summary>
|
||||
internal static string FormatStoreNotIUserAuthenticatorKeyStore()
|
||||
{
|
||||
return GetString("StoreNotIUserAuthenticatorKeyStore");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Store does not implement IUserTwoFactorStore<TUser>.
|
||||
/// </summary>
|
||||
internal static string StoreNotIUserTwoFactorStore
|
||||
{
|
||||
get { return GetString("StoreNotIUserTwoFactorStore"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Store does not implement IUserTwoFactorStore<TUser>.
|
||||
/// </summary>
|
||||
internal static string FormatStoreNotIUserTwoFactorStore()
|
||||
{
|
||||
return GetString("StoreNotIUserTwoFactorStore");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recovery code redemption failed.
|
||||
/// </summary>
|
||||
internal static string RecoveryCodeRedemptionFailed
|
||||
{
|
||||
get { return GetString("RecoveryCodeRedemptionFailed"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recovery code redemption failed.
|
||||
/// </summary>
|
||||
internal static string FormatRecoveryCodeRedemptionFailed()
|
||||
{
|
||||
return GetString("RecoveryCodeRedemptionFailed");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// User already has a password set.
|
||||
/// </summary>
|
||||
internal static string UserAlreadyHasPassword
|
||||
{
|
||||
get { return GetString("UserAlreadyHasPassword"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// User already has a password set.
|
||||
/// </summary>
|
||||
internal static string FormatUserAlreadyHasPassword()
|
||||
{
|
||||
return GetString("UserAlreadyHasPassword");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// User already in role '{0}'.
|
||||
/// </summary>
|
||||
internal static string UserAlreadyInRole
|
||||
{
|
||||
get { return GetString("UserAlreadyInRole"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// User already in role '{0}'.
|
||||
/// </summary>
|
||||
internal static string FormatUserAlreadyInRole(object p0)
|
||||
{
|
||||
return string.Format(CultureInfo.CurrentCulture, GetString("UserAlreadyInRole"), p0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// User is locked out.
|
||||
/// </summary>
|
||||
internal static string UserLockedOut
|
||||
{
|
||||
get { return GetString("UserLockedOut"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// User is locked out.
|
||||
/// </summary>
|
||||
internal static string FormatUserLockedOut()
|
||||
{
|
||||
return GetString("UserLockedOut");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Lockout is not enabled for this user.
|
||||
/// </summary>
|
||||
internal static string UserLockoutNotEnabled
|
||||
{
|
||||
get { return GetString("UserLockoutNotEnabled"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Lockout is not enabled for this user.
|
||||
/// </summary>
|
||||
internal static string FormatUserLockoutNotEnabled()
|
||||
{
|
||||
return GetString("UserLockoutNotEnabled");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// User {0} does not exist.
|
||||
/// </summary>
|
||||
internal static string UserNameNotFound
|
||||
{
|
||||
get { return GetString("UserNameNotFound"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// User {0} does not exist.
|
||||
/// </summary>
|
||||
internal static string FormatUserNameNotFound(object p0)
|
||||
{
|
||||
return string.Format(CultureInfo.CurrentCulture, GetString("UserNameNotFound"), p0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// User is not in role '{0}'.
|
||||
/// </summary>
|
||||
internal static string UserNotInRole
|
||||
{
|
||||
get { return GetString("UserNotInRole"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// User is not in role '{0}'.
|
||||
/// </summary>
|
||||
internal static string FormatUserNotInRole(object p0)
|
||||
{
|
||||
return string.Format(CultureInfo.CurrentCulture, GetString("UserNotInRole"), p0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Store does not implement IUserTwoFactorRecoveryCodeStore<User>.
|
||||
/// </summary>
|
||||
internal static string StoreNotIUserTwoFactorRecoveryCodeStore
|
||||
{
|
||||
get { return GetString("StoreNotIUserTwoFactorRecoveryCodeStore"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Store does not implement IUserTwoFactorRecoveryCodeStore<User>.
|
||||
/// </summary>
|
||||
internal static string FormatStoreNotIUserTwoFactorRecoveryCodeStore()
|
||||
{
|
||||
return GetString("StoreNotIUserTwoFactorRecoveryCodeStore");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Passwords must use at least {0} different characters.
|
||||
/// </summary>
|
||||
internal static string PasswordRequiresUniqueChars
|
||||
{
|
||||
get { return GetString("PasswordRequiresUniqueChars"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Passwords must use at least {0} different characters.
|
||||
/// </summary>
|
||||
internal static string FormatPasswordRequiresUniqueChars(object p0)
|
||||
{
|
||||
return string.Format(CultureInfo.CurrentCulture, GetString("PasswordRequiresUniqueChars"), p0);
|
||||
}
|
||||
|
||||
private static string GetString(string name, params string[] formatterNames)
|
||||
{
|
||||
var value = _resourceManager.GetString(name);
|
||||
|
||||
System.Diagnostics.Debug.Assert(value != null);
|
||||
|
||||
if (formatterNames != null)
|
||||
{
|
||||
for (var i = 0; i < formatterNames.Length; i++)
|
||||
{
|
||||
value = value.Replace("{" + formatterNames[i] + "}", "{" + i + "}");
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,308 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="ConcurrencyFailure" xml:space="preserve">
|
||||
<value>Optimistic concurrency failure, object has been modified.</value>
|
||||
<comment>Error when optimistic concurrency fails</comment>
|
||||
</data>
|
||||
<data name="DefaultError" xml:space="preserve">
|
||||
<value>An unknown failure has occurred.</value>
|
||||
<comment>Default identity result error message</comment>
|
||||
</data>
|
||||
<data name="DuplicateEmail" xml:space="preserve">
|
||||
<value>Email '{0}' is already taken.</value>
|
||||
<comment>Error for duplicate emails</comment>
|
||||
</data>
|
||||
<data name="DuplicateRoleName" xml:space="preserve">
|
||||
<value>Role name '{0}' is already taken.</value>
|
||||
<comment>Error for duplicate roles</comment>
|
||||
</data>
|
||||
<data name="DuplicateUserName" xml:space="preserve">
|
||||
<value>User name '{0}' is already taken.</value>
|
||||
<comment>Error for duplicate user names</comment>
|
||||
</data>
|
||||
<data name="InvalidEmail" xml:space="preserve">
|
||||
<value>Email '{0}' is invalid.</value>
|
||||
<comment>Invalid email</comment>
|
||||
</data>
|
||||
<data name="InvalidManagerType" xml:space="preserve">
|
||||
<value>Type {0} must derive from {1}<{2}>.</value>
|
||||
<comment>Error when the manager type is not derived correctly</comment>
|
||||
</data>
|
||||
<data name="InvalidPasswordHasherCompatibilityMode" xml:space="preserve">
|
||||
<value>The provided PasswordHasherCompatibilityMode is invalid.</value>
|
||||
<comment>Error when the password hasher doesn't understand the format it's being asked to produce.</comment>
|
||||
</data>
|
||||
<data name="InvalidPasswordHasherIterationCount" xml:space="preserve">
|
||||
<value>The iteration count must be a positive integer.</value>
|
||||
<comment>Error when the iteration count is < 1.</comment>
|
||||
</data>
|
||||
<data name="InvalidRoleName" xml:space="preserve">
|
||||
<value>Role name '{0}' is invalid.</value>
|
||||
<comment>Error for invalid role names</comment>
|
||||
</data>
|
||||
<data name="InvalidToken" xml:space="preserve">
|
||||
<value>Invalid token.</value>
|
||||
<comment>Error when a token is not recognized</comment>
|
||||
</data>
|
||||
<data name="InvalidUserName" xml:space="preserve">
|
||||
<value>User name '{0}' is invalid, can only contain letters or digits.</value>
|
||||
<comment>User names can only contain letters or digits</comment>
|
||||
</data>
|
||||
<data name="LoginAlreadyAssociated" xml:space="preserve">
|
||||
<value>A user with this login already exists.</value>
|
||||
<comment>Error when a login already linked</comment>
|
||||
</data>
|
||||
<data name="MustCallAddIdentity" xml:space="preserve">
|
||||
<value>AddIdentity must be called on the service collection.</value>
|
||||
<comment>Error when AddIdentity is not called</comment>
|
||||
</data>
|
||||
<data name="NoTokenProvider" xml:space="preserve">
|
||||
<value>No IUserTokenProvider named '{0}' is registered.</value>
|
||||
<comment>Error when there is no IUserTokenProvider</comment>
|
||||
</data>
|
||||
<data name="NullSecurityStamp" xml:space="preserve">
|
||||
<value>User security stamp cannot be null.</value>
|
||||
<comment>Error when a user's security stamp is null.</comment>
|
||||
</data>
|
||||
<data name="PasswordMismatch" xml:space="preserve">
|
||||
<value>Incorrect password.</value>
|
||||
<comment>Error when a password doesn't match</comment>
|
||||
</data>
|
||||
<data name="PasswordRequiresDigit" xml:space="preserve">
|
||||
<value>Passwords must have at least one digit ('0'-'9').</value>
|
||||
<comment>Error when passwords do not have a digit</comment>
|
||||
</data>
|
||||
<data name="PasswordRequiresLower" xml:space="preserve">
|
||||
<value>Passwords must have at least one lowercase ('a'-'z').</value>
|
||||
<comment>Error when passwords do not have a lowercase letter</comment>
|
||||
</data>
|
||||
<data name="PasswordRequiresNonAlphanumeric" xml:space="preserve">
|
||||
<value>Passwords must have at least one non alphanumeric character.</value>
|
||||
<comment>Error when password does not have enough non alphanumeric characters</comment>
|
||||
</data>
|
||||
<data name="PasswordRequiresUpper" xml:space="preserve">
|
||||
<value>Passwords must have at least one uppercase ('A'-'Z').</value>
|
||||
<comment>Error when passwords do not have an uppercase letter</comment>
|
||||
</data>
|
||||
<data name="PasswordTooShort" xml:space="preserve">
|
||||
<value>Passwords must be at least {0} characters.</value>
|
||||
<comment>Error message for passwords that are too short</comment>
|
||||
</data>
|
||||
<data name="RoleNotFound" xml:space="preserve">
|
||||
<value>Role {0} does not exist.</value>
|
||||
<comment>Error when a role does not exist</comment>
|
||||
</data>
|
||||
<data name="StoreNotIQueryableRoleStore" xml:space="preserve">
|
||||
<value>Store does not implement IQueryableRoleStore<TRole>.</value>
|
||||
<comment>Error when the store does not implement this interface</comment>
|
||||
</data>
|
||||
<data name="StoreNotIQueryableUserStore" xml:space="preserve">
|
||||
<value>Store does not implement IQueryableUserStore<TUser>.</value>
|
||||
<comment>Error when the store does not implement this interface</comment>
|
||||
</data>
|
||||
<data name="StoreNotIRoleClaimStore" xml:space="preserve">
|
||||
<value>Store does not implement IRoleClaimStore<TRole>.</value>
|
||||
<comment>Error when the store does not implement this interface</comment>
|
||||
</data>
|
||||
<data name="StoreNotIUserAuthenticationTokenStore" xml:space="preserve">
|
||||
<value>Store does not implement IUserAuthenticationTokenStore<User>.</value>
|
||||
<comment>Error when the store does not implement this interface</comment>
|
||||
</data>
|
||||
<data name="StoreNotIUserClaimStore" xml:space="preserve">
|
||||
<value>Store does not implement IUserClaimStore<TUser>.</value>
|
||||
<comment>Error when the store does not implement this interface</comment>
|
||||
</data>
|
||||
<data name="StoreNotIUserConfirmationStore" xml:space="preserve">
|
||||
<value>Store does not implement IUserConfirmationStore<TUser>.</value>
|
||||
<comment>Error when the store does not implement this interface</comment>
|
||||
</data>
|
||||
<data name="StoreNotIUserEmailStore" xml:space="preserve">
|
||||
<value>Store does not implement IUserEmailStore<TUser>.</value>
|
||||
<comment>Error when the store does not implement this interface</comment>
|
||||
</data>
|
||||
<data name="StoreNotIUserLockoutStore" xml:space="preserve">
|
||||
<value>Store does not implement IUserLockoutStore<TUser>.</value>
|
||||
<comment>Error when the store does not implement this interface</comment>
|
||||
</data>
|
||||
<data name="StoreNotIUserLoginStore" xml:space="preserve">
|
||||
<value>Store does not implement IUserLoginStore<TUser>.</value>
|
||||
<comment>Error when the store does not implement this interface</comment>
|
||||
</data>
|
||||
<data name="StoreNotIUserPasswordStore" xml:space="preserve">
|
||||
<value>Store does not implement IUserPasswordStore<TUser>.</value>
|
||||
<comment>Error when the store does not implement this interface</comment>
|
||||
</data>
|
||||
<data name="StoreNotIUserPhoneNumberStore" xml:space="preserve">
|
||||
<value>Store does not implement IUserPhoneNumberStore<TUser>.</value>
|
||||
<comment>Error when the store does not implement this interface</comment>
|
||||
</data>
|
||||
<data name="StoreNotIUserRoleStore" xml:space="preserve">
|
||||
<value>Store does not implement IUserRoleStore<TUser>.</value>
|
||||
<comment>Error when the store does not implement this interface</comment>
|
||||
</data>
|
||||
<data name="StoreNotIUserSecurityStampStore" xml:space="preserve">
|
||||
<value>Store does not implement IUserSecurityStampStore<TUser>.</value>
|
||||
<comment>Error when the store does not implement this interface</comment>
|
||||
</data>
|
||||
<data name="StoreNotIUserAuthenticatorKeyStore" xml:space="preserve">
|
||||
<value>Store does not implement IUserAuthenticatorKeyStore<User>.</value>
|
||||
<comment>Error when the store does not implement this interface</comment>
|
||||
</data>
|
||||
<data name="StoreNotIUserTwoFactorStore" xml:space="preserve">
|
||||
<value>Store does not implement IUserTwoFactorStore<TUser>.</value>
|
||||
<comment>Error when the store does not implement this interface</comment>
|
||||
</data>
|
||||
<data name="RecoveryCodeRedemptionFailed" xml:space="preserve">
|
||||
<value>Recovery code redemption failed.</value>
|
||||
<comment>Error when a recovery code is not redeemed.</comment>
|
||||
</data>
|
||||
<data name="UserAlreadyHasPassword" xml:space="preserve">
|
||||
<value>User already has a password set.</value>
|
||||
<comment>Error when AddPasswordAsync called when a user already has a password</comment>
|
||||
</data>
|
||||
<data name="UserAlreadyInRole" xml:space="preserve">
|
||||
<value>User already in role '{0}'.</value>
|
||||
<comment>Error when a user is already in a role</comment>
|
||||
</data>
|
||||
<data name="UserLockedOut" xml:space="preserve">
|
||||
<value>User is locked out.</value>
|
||||
<comment>Error when a user is locked out</comment>
|
||||
</data>
|
||||
<data name="UserLockoutNotEnabled" xml:space="preserve">
|
||||
<value>Lockout is not enabled for this user.</value>
|
||||
<comment>Error when lockout is not enabled</comment>
|
||||
</data>
|
||||
<data name="UserNameNotFound" xml:space="preserve">
|
||||
<value>User {0} does not exist.</value>
|
||||
<comment>Error when a user does not exist</comment>
|
||||
</data>
|
||||
<data name="UserNotInRole" xml:space="preserve">
|
||||
<value>User is not in role '{0}'.</value>
|
||||
<comment>Error when a user is not in the role</comment>
|
||||
</data>
|
||||
<data name="StoreNotIUserTwoFactorRecoveryCodeStore" xml:space="preserve">
|
||||
<value>Store does not implement IUserTwoFactorRecoveryCodeStore<User>.</value>
|
||||
<comment>Error when the store does not implement this interface</comment>
|
||||
</data>
|
||||
<data name="PasswordRequiresUniqueChars" xml:space="preserve">
|
||||
<value>Passwords must use at least {0} different characters.</value>
|
||||
<comment>Error message for passwords that are based on similar characters</comment>
|
||||
</data>
|
||||
</root>
|
||||
|
|
@ -7,7 +7,6 @@ using System.Linq;
|
|||
using System.Security.Claims;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Microsoft.AspNetCore.Identity
|
||||
|
|
@ -19,8 +18,11 @@ namespace Microsoft.AspNetCore.Identity
|
|||
public class RoleManager<TRole> : IDisposable where TRole : class
|
||||
{
|
||||
private bool _disposed;
|
||||
private readonly HttpContext _context;
|
||||
private CancellationToken CancellationToken => _context?.RequestAborted ?? CancellationToken.None;
|
||||
|
||||
/// <summary>
|
||||
/// The cancellation token used to cancel operations.
|
||||
/// </summary>
|
||||
protected virtual CancellationToken CancellationToken => CancellationToken.None;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new instance of <see cref="RoleManager{TRole}"/>.
|
||||
|
|
@ -30,22 +32,19 @@ namespace Microsoft.AspNetCore.Identity
|
|||
/// <param name="keyNormalizer">The normalizer to use when normalizing role names to keys.</param>
|
||||
/// <param name="errors">The <see cref="IdentityErrorDescriber"/> used to provider error messages.</param>
|
||||
/// <param name="logger">The logger used to log messages, warnings and errors.</param>
|
||||
/// <param name="contextAccessor">The accessor used to access the <see cref="HttpContext"/>.</param>
|
||||
public RoleManager(IRoleStore<TRole> store,
|
||||
IEnumerable<IRoleValidator<TRole>> roleValidators,
|
||||
ILookupNormalizer keyNormalizer,
|
||||
IdentityErrorDescriber errors,
|
||||
ILogger<RoleManager<TRole>> logger,
|
||||
IHttpContextAccessor contextAccessor)
|
||||
ILogger<RoleManager<TRole>> logger)
|
||||
{
|
||||
if (store == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(store));
|
||||
}
|
||||
Store = store;
|
||||
KeyNormalizer = keyNormalizer ?? new UpperInvariantLookupNormalizer();
|
||||
ErrorDescriber = errors ?? new IdentityErrorDescriber();
|
||||
_context = contextAccessor?.HttpContext;
|
||||
KeyNormalizer = keyNormalizer;
|
||||
ErrorDescriber = errors;
|
||||
Logger = logger;
|
||||
|
||||
if (roleValidators != null)
|
||||
|
|
@ -1,8 +1,6 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Microsoft.AspNetCore.Identity
|
||||
{
|
||||
/// <summary>
|
||||
|
|
@ -17,17 +17,17 @@ namespace Microsoft.AspNetCore.Identity
|
|||
public static readonly string DefaultProvider = "Default";
|
||||
|
||||
/// <summary>
|
||||
/// Default token provider name used by the <see cref="EmailTokenProvider{TUser}"/>.
|
||||
/// Default token provider name used by the email provider. />.
|
||||
/// </summary>
|
||||
public static readonly string DefaultEmailProvider = "Email";
|
||||
|
||||
/// <summary>
|
||||
/// Default token provider name used by the <see cref="PhoneNumberTokenProvider{TUser}"/>.
|
||||
/// Default token provider name used by the phone provider. />.
|
||||
/// </summary>
|
||||
public static readonly string DefaultPhoneProvider = "Phone";
|
||||
|
||||
/// <summary>
|
||||
/// Default token provider name used by the <see cref="AuthenticatorTokenProvider{TUser}"/>.
|
||||
/// Default token provider name used by the <see cref="AuthenticatorTokenProvider"/>.
|
||||
/// </summary>
|
||||
public static readonly string DefaultAuthenticatorProvider = "Authenticator";
|
||||
|
||||
|
|
@ -37,18 +37,18 @@ namespace Microsoft.AspNetCore.Identity
|
|||
public Dictionary<string, TokenProviderDescriptor> ProviderMap { get; set; } = new Dictionary<string, TokenProviderDescriptor>();
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the <see cref="EmailConfirmationTokenProvider"/> used to generate tokens used in account confirmation emails.
|
||||
/// Gets or sets the token provider used to generate tokens used in account confirmation emails.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The <see cref="EmailConfirmationTokenProvider"/> used to generate tokens used in account confirmation emails.
|
||||
/// The <see cref="IUserTwoFactorTokenProvider{TUser}"/> used to generate tokens used in account confirmation emails.
|
||||
/// </value>
|
||||
public string EmailConfirmationTokenProvider { get; set; } = DefaultProvider;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the <see cref="PasswordResetTokenProvider"/> used to generate tokens used in password reset emails.
|
||||
/// Gets or sets the <see cref="IUserTwoFactorTokenProvider{TUser}"/> used to generate tokens used in password reset emails.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The <see cref="PasswordResetTokenProvider"/> used to generate tokens used in password reset emails.
|
||||
/// The <see cref="IUserTwoFactorTokenProvider{TUser}"/> used to generate tokens used in password reset emails.
|
||||
/// </value>
|
||||
public string PasswordResetTokenProvider { get; set; } = DefaultProvider;
|
||||
|
||||
|
|
@ -60,6 +60,14 @@ namespace Microsoft.AspNetCore.Identity
|
|||
/// </value>
|
||||
public string ChangeEmailTokenProvider { get; set; } = DefaultProvider;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the <see cref="ChangePhoneNumberTokenProvider"/> used to generate tokens used when changing phone numbers.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The <see cref="ChangePhoneNumberTokenProvider"/> used to generate tokens used when changing phone numbers.
|
||||
/// </value>
|
||||
public string ChangePhoneNumberTokenProvider { get; set; } = DefaultProvider;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the <see cref="AuthenticatorTokenProvider"/> used to validate two factor sign ins with an authenticator.
|
||||
/// </summary>
|
||||
|
|
@ -6,11 +6,11 @@ using System.Collections.Generic;
|
|||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
|
@ -28,6 +28,11 @@ namespace Microsoft.AspNetCore.Identity
|
|||
/// </summary>
|
||||
protected const string ResetPasswordTokenPurpose = "ResetPassword";
|
||||
|
||||
/// <summary>
|
||||
/// The data protection purpose used for the change phone number methods.
|
||||
/// </summary>
|
||||
protected const string ChangePhoneNumberTokenPurpose = "ChangePhoneNumber";
|
||||
|
||||
/// <summary>
|
||||
/// The data protection purpose used for the email confirmation related methods.
|
||||
/// </summary>
|
||||
|
|
@ -38,12 +43,13 @@ namespace Microsoft.AspNetCore.Identity
|
|||
|
||||
private TimeSpan _defaultLockout = TimeSpan.Zero;
|
||||
private bool _disposed;
|
||||
private readonly HttpContext _context;
|
||||
private static readonly RandomNumberGenerator _rng = RandomNumberGenerator.Create();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The cancellation token assocated with the current HttpContext.RequestAborted or CancellationToken.None if unavailable.
|
||||
/// The cancellation token used to cancel operations.
|
||||
/// </summary>
|
||||
protected CancellationToken CancellationToken => _context?.RequestAborted ?? CancellationToken.None;
|
||||
protected virtual CancellationToken CancellationToken => CancellationToken.None;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new instance of <see cref="UserManager{TUser}"/>.
|
||||
|
|
@ -95,7 +101,6 @@ namespace Microsoft.AspNetCore.Identity
|
|||
|
||||
if (services != null)
|
||||
{
|
||||
_context = services.GetService<IHttpContextAccessor>()?.HttpContext;
|
||||
foreach (var providerName in Options.Tokens.ProviderMap.Keys)
|
||||
{
|
||||
var description = Options.Tokens.ProviderMap[providerName];
|
||||
|
|
@ -1575,12 +1580,10 @@ namespace Microsoft.AspNetCore.Identity
|
|||
/// <returns>
|
||||
/// The <see cref="Task"/> that represents the asynchronous operation, containing the telephone change number token.
|
||||
/// </returns>
|
||||
public virtual async Task<string> GenerateChangePhoneNumberTokenAsync(TUser user, string phoneNumber)
|
||||
public virtual Task<string> GenerateChangePhoneNumberTokenAsync(TUser user, string phoneNumber)
|
||||
{
|
||||
ThrowIfDisposed();
|
||||
return Rfc6238AuthenticationService.GenerateCode(
|
||||
await CreateSecurityTokenAsync(user), phoneNumber)
|
||||
.ToString(CultureInfo.InvariantCulture);
|
||||
return GenerateUserTokenAsync(user, Options.Tokens.ChangePhoneNumberTokenProvider, ChangePhoneNumberTokenPurpose + ":" + phoneNumber);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -1594,21 +1597,16 @@ namespace Microsoft.AspNetCore.Identity
|
|||
/// The <see cref="Task"/> that represents the asynchronous operation, returning true if the <paramref name="token"/>
|
||||
/// is valid, otherwise false.
|
||||
/// </returns>
|
||||
public virtual async Task<bool> VerifyChangePhoneNumberTokenAsync(TUser user, string token, string phoneNumber)
|
||||
public virtual Task<bool> VerifyChangePhoneNumberTokenAsync(TUser user, string token, string phoneNumber)
|
||||
{
|
||||
ThrowIfDisposed();
|
||||
|
||||
var securityToken = await CreateSecurityTokenAsync(user);
|
||||
int code;
|
||||
if (securityToken != null && Int32.TryParse(token, out code))
|
||||
if (user == null)
|
||||
{
|
||||
if (Rfc6238AuthenticationService.ValidateCode(securityToken, code, phoneNumber))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
throw new ArgumentNullException(nameof(user));
|
||||
}
|
||||
Logger.LogWarning(8, "VerifyChangePhoneNumberTokenAsync() failed for user {userId}.", await GetUserIdAsync(user));
|
||||
return false;
|
||||
|
||||
// Make sure the token is valid and the stamp matches
|
||||
return VerifyUserTokenAsync(user, Options.Tokens.ChangePhoneNumberTokenProvider, ChangePhoneNumberTokenPurpose+":"+ phoneNumber, token);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -2159,7 +2157,9 @@ namespace Microsoft.AspNetCore.Identity
|
|||
/// <returns>The new security secret.</returns>
|
||||
public virtual string GenerateNewAuthenticatorKey()
|
||||
{
|
||||
return Base32.ToBase32(Rfc6238AuthenticationService.GenerateRandomKey());
|
||||
byte[] bytes = new byte[20];
|
||||
_rng.GetBytes(bytes);
|
||||
return Base32.ToBase32(bytes);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -2278,7 +2278,12 @@ namespace Microsoft.AspNetCore.Identity
|
|||
return cast;
|
||||
}
|
||||
|
||||
internal async Task<byte[]> CreateSecurityTokenAsync(TUser user)
|
||||
/// <summary>
|
||||
/// Creates bytes to use as a security token from the user's security stamp.
|
||||
/// </summary>
|
||||
/// <param name="user">The user.</param>
|
||||
/// <returns>The security token bytes.</returns>
|
||||
public virtual async Task<byte[]> CreateSecurityTokenAsync(TUser user)
|
||||
{
|
||||
return Encoding.Unicode.GetBytes(await GetSecurityStampAsync(user));
|
||||
}
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore
|
||||
namespace Microsoft.AspNetCore.Identity
|
||||
{
|
||||
/// <summary>
|
||||
/// The default implementation of <see cref="IdentityRole{TKey}"/> which uses a string as the primary key.
|
||||
|
|
@ -82,16 +82,6 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore
|
|||
Name = roleName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Navigation property for the users in this role.
|
||||
/// </summary>
|
||||
public virtual ICollection<TUserRole> Users { get; } = new List<TUserRole>();
|
||||
|
||||
/// <summary>
|
||||
/// Navigation property for claims in this role.
|
||||
/// </summary>
|
||||
public virtual ICollection<TRoleClaim> Claims { get; } = new List<TRoleClaim>();
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the primary key for this role.
|
||||
/// </summary>
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
using System;
|
||||
using System.Security.Claims;
|
||||
|
||||
namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore
|
||||
namespace Microsoft.AspNetCore.Identity
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a claim that is granted to all users within a role.
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore
|
||||
namespace Microsoft.AspNetCore.Identity
|
||||
{
|
||||
/// <summary>
|
||||
/// The default implementation of <see cref="IdentityUser{TKey}"/> which uses a string as a primary key.
|
||||
|
|
@ -149,26 +149,6 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore
|
|||
/// </summary>
|
||||
public virtual int AccessFailedCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Navigation property for the roles this user belongs to.
|
||||
/// </summary>
|
||||
public virtual ICollection<TUserRole> Roles { get; } = new List<TUserRole>();
|
||||
|
||||
/// <summary>
|
||||
/// Navigation property for the claims this user possesses.
|
||||
/// </summary>
|
||||
public virtual ICollection<TUserClaim> Claims { get; } = new List<TUserClaim>();
|
||||
|
||||
/// <summary>
|
||||
/// Navigation property for this users login accounts.
|
||||
/// </summary>
|
||||
public virtual ICollection<TUserLogin> Logins { get; } = new List<TUserLogin>();
|
||||
|
||||
/// <summary>
|
||||
/// Navigation property for this users tokens.
|
||||
/// </summary>
|
||||
public virtual ICollection<TUserToken> Tokens { get; } = new List<TUserToken>();
|
||||
|
||||
/// <summary>
|
||||
/// Returns the username for this user.
|
||||
/// </summary>
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
using System;
|
||||
using System.Security.Claims;
|
||||
|
||||
namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore
|
||||
namespace Microsoft.AspNetCore.Identity
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a claim that a user possesses.
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
using System;
|
||||
|
||||
namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore
|
||||
namespace Microsoft.AspNetCore.Identity
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a login and its associated provider for a user.
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
using System;
|
||||
|
||||
namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore
|
||||
namespace Microsoft.AspNetCore.Identity
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the link between a user and a role.
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
using System;
|
||||
|
||||
namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore
|
||||
namespace Microsoft.AspNetCore.Identity
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents an authentication token for a user.
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<Import Project="..\..\build\common.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<Description>ASP.NET Core Identity is the membership system for building ASP.NET Core web applications, including membership, login, and user data. ASP.NET Core Identity allows you to add login features to your application and makes it easy to customize data about the logged in user.</Description>
|
||||
<TargetFramework>netstandard1.3</TargetFramework>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<PackageTags>aspnetcore;identity;membership</PackageTags>
|
||||
<EnableApiCheck>false</EnableApiCheck>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="$(AspNetCoreVersion)" />
|
||||
<PackageReference Include="Microsoft.Extensions.TaskCache.Sources" Version="$(AspNetCoreVersion)" PrivateAssets="All" />
|
||||
<PackageReference Include="System.ComponentModel.Annotations" Version="$(CoreFxVersion)" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.3' ">
|
||||
<PackageReference Include="System.ComponentModel.TypeConverter" Version="$(CoreFxVersion)" />
|
||||
<PackageReference Include="System.Security.Claims" Version="$(CoreFxVersion)" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Microsoft.Extensions.Identity.Core\Microsoft.Extensions.Identity.Core.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
@ -0,0 +1,272 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.Internal;
|
||||
|
||||
namespace Microsoft.AspNetCore.Identity
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new instance of a persistence store for roles.
|
||||
/// </summary>
|
||||
/// <typeparam name="TRole">The type of the class representing a role.</typeparam>
|
||||
/// <typeparam name="TKey">The type of the primary key for a role.</typeparam>
|
||||
/// <typeparam name="TUserRole">The type of the class representing a user role.</typeparam>
|
||||
/// <typeparam name="TRoleClaim">The type of the class representing a role claim.</typeparam>
|
||||
public abstract class RoleStoreBase<TRole, TKey, TUserRole, TRoleClaim> :
|
||||
IQueryableRoleStore<TRole>,
|
||||
IRoleClaimStore<TRole>
|
||||
where TRole : IdentityRole<TKey, TUserRole, TRoleClaim>
|
||||
where TKey : IEquatable<TKey>
|
||||
where TUserRole : IdentityUserRole<TKey>, new()
|
||||
where TRoleClaim : IdentityRoleClaim<TKey>, new()
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructs a new instance of <see cref="RoleStoreBase{TRole, TKey, TUserRole, TRoleClaim}"/>.
|
||||
/// </summary>
|
||||
/// <param name="describer">The <see cref="IdentityErrorDescriber"/>.</param>
|
||||
public RoleStoreBase(IdentityErrorDescriber describer)
|
||||
{
|
||||
if (describer == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(describer));
|
||||
}
|
||||
|
||||
ErrorDescriber = describer;
|
||||
}
|
||||
|
||||
private bool _disposed;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the <see cref="IdentityErrorDescriber"/> for any error that occurred with the current operation.
|
||||
/// </summary>
|
||||
public IdentityErrorDescriber ErrorDescriber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new role in a store as an asynchronous operation.
|
||||
/// </summary>
|
||||
/// <param name="role">The role to create in the store.</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
|
||||
/// <returns>A <see cref="Task{TResult}"/> that represents the <see cref="IdentityResult"/> of the asynchronous query.</returns>
|
||||
public abstract Task<IdentityResult> CreateAsync(TRole role, CancellationToken cancellationToken = default(CancellationToken));
|
||||
|
||||
/// <summary>
|
||||
/// Updates a role in a store as an asynchronous operation.
|
||||
/// </summary>
|
||||
/// <param name="role">The role to update in the store.</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
|
||||
/// <returns>A <see cref="Task{TResult}"/> that represents the <see cref="IdentityResult"/> of the asynchronous query.</returns>
|
||||
public abstract Task<IdentityResult> UpdateAsync(TRole role, CancellationToken cancellationToken = default(CancellationToken));
|
||||
|
||||
/// <summary>
|
||||
/// Deletes a role from the store as an asynchronous operation.
|
||||
/// </summary>
|
||||
/// <param name="role">The role to delete from the store.</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
|
||||
/// <returns>A <see cref="Task{TResult}"/> that represents the <see cref="IdentityResult"/> of the asynchronous query.</returns>
|
||||
public abstract Task<IdentityResult> DeleteAsync(TRole role, CancellationToken cancellationToken = default(CancellationToken));
|
||||
|
||||
/// <summary>
|
||||
/// Gets the ID for a role from the store as an asynchronous operation.
|
||||
/// </summary>
|
||||
/// <param name="role">The role whose ID should be returned.</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
|
||||
/// <returns>A <see cref="Task{TResult}"/> that contains the ID of the role.</returns>
|
||||
public virtual Task<string> GetRoleIdAsync(TRole role, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
ThrowIfDisposed();
|
||||
if (role == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(role));
|
||||
}
|
||||
return Task.FromResult(ConvertIdToString(role.Id));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of a role from the store as an asynchronous operation.
|
||||
/// </summary>
|
||||
/// <param name="role">The role whose name should be returned.</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
|
||||
/// <returns>A <see cref="Task{TResult}"/> that contains the name of the role.</returns>
|
||||
public virtual Task<string> GetRoleNameAsync(TRole role, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
ThrowIfDisposed();
|
||||
if (role == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(role));
|
||||
}
|
||||
return Task.FromResult(role.Name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the name of a role in the store as an asynchronous operation.
|
||||
/// </summary>
|
||||
/// <param name="role">The role whose name should be set.</param>
|
||||
/// <param name="roleName">The name of the role.</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
|
||||
/// <returns>The <see cref="Task"/> that represents the asynchronous operation.</returns>
|
||||
public virtual Task SetRoleNameAsync(TRole role, string roleName, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
ThrowIfDisposed();
|
||||
if (role == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(role));
|
||||
}
|
||||
role.Name = roleName;
|
||||
return TaskCache.CompletedTask;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the provided <paramref name="id"/> to a strongly typed key object.
|
||||
/// </summary>
|
||||
/// <param name="id">The id to convert.</param>
|
||||
/// <returns>An instance of <typeparamref name="TKey"/> representing the provided <paramref name="id"/>.</returns>
|
||||
public virtual TKey ConvertIdFromString(string id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return default(TKey);
|
||||
}
|
||||
return (TKey)TypeDescriptor.GetConverter(typeof(TKey)).ConvertFromInvariantString(id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the provided <paramref name="id"/> to its string representation.
|
||||
/// </summary>
|
||||
/// <param name="id">The id to convert.</param>
|
||||
/// <returns>An <see cref="string"/> representation of the provided <paramref name="id"/>.</returns>
|
||||
public virtual string ConvertIdToString(TKey id)
|
||||
{
|
||||
if (id.Equals(default(TKey)))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return id.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Finds the role who has the specified ID as an asynchronous operation.
|
||||
/// </summary>
|
||||
/// <param name="id">The role ID to look for.</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
|
||||
/// <returns>A <see cref="Task{TResult}"/> that result of the look up.</returns>
|
||||
public abstract Task<TRole> FindByIdAsync(string id, CancellationToken cancellationToken = default(CancellationToken));
|
||||
|
||||
/// <summary>
|
||||
/// Finds the role who has the specified normalized name as an asynchronous operation.
|
||||
/// </summary>
|
||||
/// <param name="normalizedName">The normalized role name to look for.</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
|
||||
/// <returns>A <see cref="Task{TResult}"/> that result of the look up.</returns>
|
||||
public abstract Task<TRole> FindByNameAsync(string normalizedName, CancellationToken cancellationToken = default(CancellationToken));
|
||||
|
||||
/// <summary>
|
||||
/// Get a role's normalized name as an asynchronous operation.
|
||||
/// </summary>
|
||||
/// <param name="role">The role whose normalized name should be retrieved.</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
|
||||
/// <returns>A <see cref="Task{TResult}"/> that contains the name of the role.</returns>
|
||||
public virtual Task<string> GetNormalizedRoleNameAsync(TRole role, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
ThrowIfDisposed();
|
||||
if (role == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(role));
|
||||
}
|
||||
return Task.FromResult(role.NormalizedName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set a role's normalized name as an asynchronous operation.
|
||||
/// </summary>
|
||||
/// <param name="role">The role whose normalized name should be set.</param>
|
||||
/// <param name="normalizedName">The normalized name to set</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
|
||||
/// <returns>The <see cref="Task"/> that represents the asynchronous operation.</returns>
|
||||
public virtual Task SetNormalizedRoleNameAsync(TRole role, string normalizedName, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
ThrowIfDisposed();
|
||||
if (role == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(role));
|
||||
}
|
||||
role.NormalizedName = normalizedName;
|
||||
return TaskCache.CompletedTask;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws if this class has been disposed.
|
||||
/// </summary>
|
||||
protected void ThrowIfDisposed()
|
||||
{
|
||||
if (_disposed)
|
||||
{
|
||||
throw new ObjectDisposedException(GetType().Name);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dispose the stores
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
_disposed = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the claims associated with the specified <paramref name="role"/> as an asynchronous operation.
|
||||
/// </summary>
|
||||
/// <param name="role">The role whose claims should be retrieved.</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
|
||||
/// <returns>A <see cref="Task{TResult}"/> that contains the claims granted to a role.</returns>
|
||||
public abstract Task<IList<Claim>> GetClaimsAsync(TRole role, CancellationToken cancellationToken = default(CancellationToken));
|
||||
|
||||
/// <summary>
|
||||
/// Adds the <paramref name="claim"/> given to the specified <paramref name="role"/>.
|
||||
/// </summary>
|
||||
/// <param name="role">The role to add the claim to.</param>
|
||||
/// <param name="claim">The claim to add to the role.</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
|
||||
/// <returns>The <see cref="Task"/> that represents the asynchronous operation.</returns>
|
||||
public abstract Task AddClaimAsync(TRole role, Claim claim, CancellationToken cancellationToken = default(CancellationToken));
|
||||
|
||||
/// <summary>
|
||||
/// Removes the <paramref name="claim"/> given from the specified <paramref name="role"/>.
|
||||
/// </summary>
|
||||
/// <param name="role">The role to remove the claim from.</param>
|
||||
/// <param name="claim">The claim to remove from the role.</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
|
||||
/// <returns>The <see cref="Task"/> that represents the asynchronous operation.</returns>
|
||||
public abstract Task RemoveClaimAsync(TRole role, Claim claim, CancellationToken cancellationToken = default(CancellationToken));
|
||||
|
||||
/// <summary>
|
||||
/// A navigation property for the roles the store contains.
|
||||
/// </summary>
|
||||
public abstract IQueryable<TRole> Roles
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a entity representing a role claim.
|
||||
/// </summary>
|
||||
/// <param name="role">The associated role.</param>
|
||||
/// <param name="claim">The associated claim.</param>
|
||||
/// <returns>The role claim entity.</returns>
|
||||
protected virtual TRoleClaim CreateRoleClaim(TRole role, Claim claim)
|
||||
{
|
||||
return new TRoleClaim { RoleId = role.Id, ClaimType = claim.Type, ClaimValue = claim.Value };
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -60,127 +60,5 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore.Test
|
|||
IdentityResultAssert.IsSuccess(await userManager.CreateAsync(user, password));
|
||||
IdentityResultAssert.IsSuccess(await userManager.DeleteAsync(user));
|
||||
}
|
||||
|
||||
[ConditionalFact]
|
||||
[FrameworkSkipCondition(RuntimeFrameworks.Mono)]
|
||||
[OSSkipCondition(OperatingSystems.Linux)]
|
||||
[OSSkipCondition(OperatingSystems.MacOSX)]
|
||||
public async Task CanIncludeUserClaimsTest()
|
||||
{
|
||||
// Arrange
|
||||
var userManager = _builder.ApplicationServices.GetRequiredService<UserManager<IdentityUser>>();
|
||||
var dbContext = _builder.ApplicationServices.GetRequiredService<IdentityDbContext>();
|
||||
|
||||
var username = "user" + new Random().Next();
|
||||
var user = new IdentityUser() { UserName = username };
|
||||
IdentityResultAssert.IsSuccess(await userManager.CreateAsync(user));
|
||||
|
||||
for (var i = 0; i < 10; i++)
|
||||
{
|
||||
IdentityResultAssert.IsSuccess(await userManager.AddClaimAsync(user, new Claim(i.ToString(), "foo")));
|
||||
}
|
||||
|
||||
user = dbContext.Users.Include(x => x.Claims).FirstOrDefault(x => x.UserName == username);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(user);
|
||||
Assert.NotNull(user.Claims);
|
||||
Assert.Equal(10, user.Claims.Count());
|
||||
}
|
||||
|
||||
[ConditionalFact]
|
||||
[FrameworkSkipCondition(RuntimeFrameworks.Mono)]
|
||||
[OSSkipCondition(OperatingSystems.Linux)]
|
||||
[OSSkipCondition(OperatingSystems.MacOSX)]
|
||||
public async Task CanIncludeUserLoginsTest()
|
||||
{
|
||||
// Arrange
|
||||
var userManager = _builder.ApplicationServices.GetRequiredService<UserManager<IdentityUser>>();
|
||||
var dbContext = _builder.ApplicationServices.GetRequiredService<IdentityDbContext>();
|
||||
|
||||
var username = "user" + new Random().Next();
|
||||
var user = new IdentityUser() { UserName = username };
|
||||
IdentityResultAssert.IsSuccess(await userManager.CreateAsync(user));
|
||||
|
||||
for (var i = 0; i < 10; i++)
|
||||
{
|
||||
IdentityResultAssert.IsSuccess(await userManager.AddLoginAsync(user, new UserLoginInfo("foo" + i, "bar" + i, "foo")));
|
||||
}
|
||||
|
||||
user = dbContext.Users.Include(x => x.Logins).FirstOrDefault(x => x.UserName == username);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(user);
|
||||
Assert.NotNull(user.Logins);
|
||||
Assert.Equal(10, user.Logins.Count());
|
||||
}
|
||||
|
||||
[ConditionalFact]
|
||||
[FrameworkSkipCondition(RuntimeFrameworks.Mono)]
|
||||
[OSSkipCondition(OperatingSystems.Linux)]
|
||||
[OSSkipCondition(OperatingSystems.MacOSX)]
|
||||
public async Task CanIncludeUserRolesTest()
|
||||
{
|
||||
// Arrange
|
||||
var userManager = _builder.ApplicationServices.GetRequiredService<UserManager<IdentityUser>>();
|
||||
var roleManager = _builder.ApplicationServices.GetRequiredService<RoleManager<IdentityRole>>();
|
||||
var dbContext = _builder.ApplicationServices.GetRequiredService<IdentityDbContext>();
|
||||
|
||||
const string roleName = "Admin";
|
||||
for (var i = 0; i < 10; i++)
|
||||
{
|
||||
IdentityResultAssert.IsSuccess(await roleManager.CreateAsync(new IdentityRole(roleName + i)));
|
||||
}
|
||||
var username = "user" + new Random().Next();
|
||||
var user = new IdentityUser() { UserName = username };
|
||||
IdentityResultAssert.IsSuccess(await userManager.CreateAsync(user));
|
||||
|
||||
for (var i = 0; i < 10; i++)
|
||||
{
|
||||
IdentityResultAssert.IsSuccess(await userManager.AddToRoleAsync(user, roleName + i));
|
||||
}
|
||||
|
||||
user = dbContext.Users.Include(x => x.Roles).FirstOrDefault(x => x.UserName == username);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(user);
|
||||
Assert.NotNull(user.Roles);
|
||||
Assert.Equal(10, user.Roles.Count());
|
||||
|
||||
for (var i = 0; i < 10; i++)
|
||||
{
|
||||
var role = dbContext.Roles.Include(r => r.Users).FirstOrDefault(r => r.Name == (roleName + i));
|
||||
Assert.NotNull(role);
|
||||
Assert.NotNull(role.Users);
|
||||
Assert.Equal(1, role.Users.Count());
|
||||
}
|
||||
}
|
||||
|
||||
[ConditionalFact]
|
||||
[FrameworkSkipCondition(RuntimeFrameworks.Mono)]
|
||||
[OSSkipCondition(OperatingSystems.Linux)]
|
||||
[OSSkipCondition(OperatingSystems.MacOSX)]
|
||||
public async Task CanIncludeRoleClaimsTest()
|
||||
{
|
||||
// Arrange
|
||||
var roleManager = _builder.ApplicationServices.GetRequiredService<RoleManager<IdentityRole>>();
|
||||
var dbContext = _builder.ApplicationServices.GetRequiredService<IdentityDbContext>();
|
||||
|
||||
var role = new IdentityRole("Admin");
|
||||
|
||||
IdentityResultAssert.IsSuccess(await roleManager.CreateAsync(role));
|
||||
|
||||
for (var i = 0; i < 10; i++)
|
||||
{
|
||||
IdentityResultAssert.IsSuccess(await roleManager.AddClaimAsync(role, new Claim("foo" + i, "bar" + i)));
|
||||
}
|
||||
|
||||
role = dbContext.Roles.Include(x => x.Claims).FirstOrDefault(x => x.Name == "Admin");
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(role);
|
||||
Assert.NotNull(role.Claims);
|
||||
Assert.Equal(10, role.Claims.Count());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -23,7 +23,7 @@ namespace Microsoft.AspNetCore.Identity.InMemory.Test
|
|||
{
|
||||
var context = new DefaultHttpContext();
|
||||
var auth = MockAuth(context);
|
||||
auth.Setup(a => a.SignInAsync(context, new IdentityCookieOptions().ApplicationCookieAuthenticationScheme,
|
||||
auth.Setup(a => a.SignInAsync(context, IdentityConstants.ApplicationScheme,
|
||||
It.IsAny<ClaimsPrincipal>(),
|
||||
It.IsAny<AuthenticationProperties>())).Returns(Task.FromResult(0)).Verifiable();
|
||||
// REVIEW: is persistant mocking broken
|
||||
|
|
|
|||
|
|
@ -137,9 +137,9 @@ namespace Microsoft.AspNetCore.Identity.InMemory
|
|||
var clock = new TestClock();
|
||||
var server = CreateServer(services =>
|
||||
{
|
||||
services.Configure<IdentityOptions>(options =>
|
||||
services.Configure<SecurityStampValidatorOptions>(options =>
|
||||
{
|
||||
options.OnSecurityStampRefreshingPrincipal = c =>
|
||||
options.OnRefreshingPrincipal = c =>
|
||||
{
|
||||
var newId = new ClaimsIdentity();
|
||||
newId.AddClaim(new Claim("PreviousName", c.CurrentPrincipal.Identity.Name));
|
||||
|
|
@ -195,7 +195,7 @@ namespace Microsoft.AspNetCore.Identity.InMemory
|
|||
Assert.Equal(HttpStatusCode.OK, transaction2.Response.StatusCode);
|
||||
|
||||
var setCookie = transaction2.SetCookie;
|
||||
Assert.Contains(new IdentityCookieOptions().TwoFactorRememberMeCookieAuthenticationScheme + "=", setCookie);
|
||||
Assert.Contains(IdentityConstants.TwoFactorRememberMeScheme + "=", setCookie);
|
||||
Assert.Contains("; expires=", setCookie);
|
||||
|
||||
var transaction3 = await SendAsync(server, "http://example.com/isTwoFactorRememebered", transaction2.CookieNameValue);
|
||||
|
|
|
|||
|
|
@ -321,7 +321,7 @@ namespace Microsoft.AspNetCore.Identity.Test
|
|||
private class MyRoleManager : RoleManager<TestRole>
|
||||
{
|
||||
public MyRoleManager(IRoleStore<TestRole> store,
|
||||
IEnumerable<IRoleValidator<TestRole>> roleValidators) : base(store, null, null, null, null, null)
|
||||
IEnumerable<IRoleValidator<TestRole>> roleValidators) : base(store, null, null, null, null)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNetCore.Identity.Test
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ namespace Microsoft.AspNetCore.Identity.Test
|
|||
public async Task RoleManagerPublicNullChecks()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>("store",
|
||||
() => new RoleManager<TestRole>(null, null, null, null, null, null));
|
||||
() => new RoleManager<TestRole>(null, null, null, null, null));
|
||||
var manager = CreateRoleManager(new NotImplementedStore());
|
||||
await Assert.ThrowsAsync<ArgumentNullException>("role", async () => await manager.CreateAsync(null));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>("role", async () => await manager.UpdateAsync(null));
|
||||
|
|
|
|||
|
|
@ -55,9 +55,9 @@ namespace Microsoft.AspNetCore.Identity.Test
|
|||
{
|
||||
var httpContext = new Mock<HttpContext>();
|
||||
httpContext.Setup(c => c.RequestServices).Returns(new ServiceCollection().BuildServiceProvider());
|
||||
var id = new ClaimsPrincipal(new ClaimsIdentity(IdentityCookieOptions.ApplicationScheme));
|
||||
var ticket = new AuthenticationTicket(id, new AuthenticationProperties { IssuedUtc = DateTimeOffset.UtcNow }, IdentityCookieOptions.ApplicationScheme);
|
||||
var context = new CookieValidatePrincipalContext(httpContext.Object, new AuthenticationSchemeBuilder(IdentityCookieOptions.ApplicationScheme) { HandlerType = typeof(NoopHandler) }.Build(), ticket, new CookieAuthenticationOptions());
|
||||
var id = new ClaimsPrincipal(new ClaimsIdentity(IdentityConstants.ApplicationScheme));
|
||||
var ticket = new AuthenticationTicket(id, new AuthenticationProperties { IssuedUtc = DateTimeOffset.UtcNow }, IdentityConstants.ApplicationScheme);
|
||||
var context = new CookieValidatePrincipalContext(httpContext.Object, new AuthenticationSchemeBuilder(IdentityConstants.ApplicationScheme) { HandlerType = typeof(NoopHandler) }.Build(), ticket, new CookieAuthenticationOptions());
|
||||
var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => SecurityStampValidator.ValidatePrincipalAsync(context));
|
||||
}
|
||||
|
||||
|
|
@ -69,19 +69,20 @@ namespace Microsoft.AspNetCore.Identity.Test
|
|||
var user = new TestUser("test");
|
||||
var userManager = MockHelpers.MockUserManager<TestUser>();
|
||||
var claimsManager = new Mock<IUserClaimsPrincipalFactory<TestUser>>();
|
||||
var identityOptions = new IdentityOptions { SecurityStampValidationInterval = TimeSpan.Zero };
|
||||
var options = new Mock<IOptions<IdentityOptions>>();
|
||||
options.Setup(a => a.Value).Returns(identityOptions);
|
||||
var identityOptions = new Mock<IOptions<IdentityOptions>>();
|
||||
identityOptions.Setup(a => a.Value).Returns(new IdentityOptions());
|
||||
var options = new Mock<IOptions<SecurityStampValidatorOptions>>();
|
||||
options.Setup(a => a.Value).Returns(new SecurityStampValidatorOptions { ValidationInterval = TimeSpan.Zero });
|
||||
var httpContext = new Mock<HttpContext>();
|
||||
var contextAccessor = new Mock<IHttpContextAccessor>();
|
||||
contextAccessor.Setup(a => a.HttpContext).Returns(httpContext.Object);
|
||||
var id = new ClaimsIdentity(identityOptions.Cookies.ApplicationCookieAuthenticationScheme);
|
||||
var id = new ClaimsIdentity(IdentityConstants.ApplicationScheme);
|
||||
id.AddClaim(new Claim(ClaimTypes.NameIdentifier, user.Id));
|
||||
var principal = new ClaimsPrincipal(id);
|
||||
|
||||
var properties = new AuthenticationProperties { IssuedUtc = DateTimeOffset.UtcNow.AddSeconds(-1), IsPersistent = isPersistent };
|
||||
var signInManager = new Mock<SignInManager<TestUser>>(userManager.Object,
|
||||
contextAccessor.Object, claimsManager.Object, options.Object, null, new Mock<IAuthenticationSchemeProvider>().Object);
|
||||
contextAccessor.Object, claimsManager.Object, identityOptions.Object, null, new Mock<IAuthenticationSchemeProvider>().Object);
|
||||
signInManager.Setup(s => s.ValidateSecurityStampAsync(It.IsAny<ClaimsPrincipal>())).ReturnsAsync(user).Verifiable();
|
||||
signInManager.Setup(s => s.CreateUserPrincipalAsync(user)).ReturnsAsync(principal).Verifiable();
|
||||
var services = new ServiceCollection();
|
||||
|
|
@ -92,8 +93,8 @@ namespace Microsoft.AspNetCore.Identity.Test
|
|||
|
||||
var ticket = new AuthenticationTicket(principal,
|
||||
properties,
|
||||
identityOptions.Cookies.ApplicationCookieAuthenticationScheme);
|
||||
var context = new CookieValidatePrincipalContext(httpContext.Object, new AuthenticationSchemeBuilder(identityOptions.Cookies.ApplicationCookieAuthenticationScheme) { HandlerType = typeof(NoopHandler) }.Build(), ticket, new CookieAuthenticationOptions());
|
||||
IdentityConstants.ApplicationScheme);
|
||||
var context = new CookieValidatePrincipalContext(httpContext.Object, new AuthenticationSchemeBuilder(IdentityConstants.ApplicationScheme) { HandlerType = typeof(NoopHandler) }.Build(), ticket, new CookieAuthenticationOptions());
|
||||
Assert.NotNull(context.Properties);
|
||||
Assert.NotNull(context.Options);
|
||||
Assert.NotNull(context.Principal);
|
||||
|
|
@ -109,27 +110,28 @@ namespace Microsoft.AspNetCore.Identity.Test
|
|||
var user = new TestUser("test");
|
||||
var userManager = MockHelpers.MockUserManager<TestUser>();
|
||||
var claimsManager = new Mock<IUserClaimsPrincipalFactory<TestUser>>();
|
||||
var identityOptions = new IdentityOptions { SecurityStampValidationInterval = TimeSpan.Zero };
|
||||
var options = new Mock<IOptions<IdentityOptions>>();
|
||||
options.Setup(a => a.Value).Returns(identityOptions);
|
||||
var identityOptions = new Mock<IOptions<IdentityOptions>>();
|
||||
identityOptions.Setup(a => a.Value).Returns(new IdentityOptions());
|
||||
var options = new Mock<IOptions<SecurityStampValidatorOptions>>();
|
||||
options.Setup(a => a.Value).Returns(new SecurityStampValidatorOptions { ValidationInterval = TimeSpan.Zero });
|
||||
var httpContext = new Mock<HttpContext>();
|
||||
var contextAccessor = new Mock<IHttpContextAccessor>();
|
||||
contextAccessor.Setup(a => a.HttpContext).Returns(httpContext.Object);
|
||||
var signInManager = new Mock<SignInManager<TestUser>>(userManager.Object,
|
||||
contextAccessor.Object, claimsManager.Object, options.Object, null, new Mock<IAuthenticationSchemeProvider>().Object);
|
||||
contextAccessor.Object, claimsManager.Object, identityOptions.Object, null, new Mock<IAuthenticationSchemeProvider>().Object);
|
||||
signInManager.Setup(s => s.ValidateSecurityStampAsync(It.IsAny<ClaimsPrincipal>())).ReturnsAsync(default(TestUser)).Verifiable();
|
||||
var services = new ServiceCollection();
|
||||
services.AddSingleton(options.Object);
|
||||
services.AddSingleton(signInManager.Object);
|
||||
services.AddSingleton<ISecurityStampValidator>(new SecurityStampValidator<TestUser>(options.Object, signInManager.Object, new SystemClock()));
|
||||
httpContext.Setup(c => c.RequestServices).Returns(services.BuildServiceProvider());
|
||||
var id = new ClaimsIdentity(identityOptions.Cookies.ApplicationCookieAuthenticationScheme);
|
||||
var id = new ClaimsIdentity(IdentityConstants.ApplicationScheme);
|
||||
id.AddClaim(new Claim(ClaimTypes.NameIdentifier, user.Id));
|
||||
|
||||
var ticket = new AuthenticationTicket(new ClaimsPrincipal(id),
|
||||
new AuthenticationProperties { IssuedUtc = DateTimeOffset.UtcNow.AddSeconds(-1) },
|
||||
identityOptions.Cookies.ApplicationCookieAuthenticationScheme);
|
||||
var context = new CookieValidatePrincipalContext(httpContext.Object, new AuthenticationSchemeBuilder(identityOptions.Cookies.ApplicationCookieAuthenticationScheme) { HandlerType = typeof(NoopHandler) }.Build(), ticket, new CookieAuthenticationOptions());
|
||||
IdentityConstants.ApplicationScheme);
|
||||
var context = new CookieValidatePrincipalContext(httpContext.Object, new AuthenticationSchemeBuilder(IdentityConstants.ApplicationScheme) { HandlerType = typeof(NoopHandler) }.Build(), ticket, new CookieAuthenticationOptions());
|
||||
Assert.NotNull(context.Properties);
|
||||
Assert.NotNull(context.Options);
|
||||
Assert.NotNull(context.Principal);
|
||||
|
|
@ -144,27 +146,28 @@ namespace Microsoft.AspNetCore.Identity.Test
|
|||
var user = new TestUser("test");
|
||||
var httpContext = new Mock<HttpContext>();
|
||||
var userManager = MockHelpers.MockUserManager<TestUser>();
|
||||
var identityOptions = new Mock<IOptions<IdentityOptions>>();
|
||||
identityOptions.Setup(a => a.Value).Returns(new IdentityOptions());
|
||||
var claimsManager = new Mock<IUserClaimsPrincipalFactory<TestUser>>();
|
||||
var identityOptions = new IdentityOptions { SecurityStampValidationInterval = TimeSpan.Zero };
|
||||
var options = new Mock<IOptions<IdentityOptions>>();
|
||||
options.Setup(a => a.Value).Returns(identityOptions);
|
||||
var options = new Mock<IOptions<SecurityStampValidatorOptions>>();
|
||||
options.Setup(a => a.Value).Returns(new SecurityStampValidatorOptions { ValidationInterval = TimeSpan.Zero });
|
||||
var contextAccessor = new Mock<IHttpContextAccessor>();
|
||||
contextAccessor.Setup(a => a.HttpContext).Returns(httpContext.Object);
|
||||
var signInManager = new Mock<SignInManager<TestUser>>(userManager.Object,
|
||||
contextAccessor.Object, claimsManager.Object, options.Object, null, new Mock<IAuthenticationSchemeProvider>().Object);
|
||||
contextAccessor.Object, claimsManager.Object, identityOptions.Object, null, new Mock<IAuthenticationSchemeProvider>().Object);
|
||||
signInManager.Setup(s => s.ValidateSecurityStampAsync(It.IsAny<ClaimsPrincipal>())).ReturnsAsync(default(TestUser)).Verifiable();
|
||||
var services = new ServiceCollection();
|
||||
services.AddSingleton(options.Object);
|
||||
services.AddSingleton(signInManager.Object);
|
||||
services.AddSingleton<ISecurityStampValidator>(new SecurityStampValidator<TestUser>(options.Object, signInManager.Object, new SystemClock()));
|
||||
httpContext.Setup(c => c.RequestServices).Returns(services.BuildServiceProvider());
|
||||
var id = new ClaimsIdentity(identityOptions.Cookies.ApplicationCookieAuthenticationScheme);
|
||||
var id = new ClaimsIdentity(IdentityConstants.ApplicationScheme);
|
||||
id.AddClaim(new Claim(ClaimTypes.NameIdentifier, user.Id));
|
||||
|
||||
var ticket = new AuthenticationTicket(new ClaimsPrincipal(id),
|
||||
new AuthenticationProperties(),
|
||||
identityOptions.Cookies.ApplicationCookieAuthenticationScheme);
|
||||
var context = new CookieValidatePrincipalContext(httpContext.Object, new AuthenticationSchemeBuilder(identityOptions.Cookies.ApplicationCookieAuthenticationScheme) { HandlerType = typeof(NoopHandler) }.Build(), ticket, new CookieAuthenticationOptions());
|
||||
IdentityConstants.ApplicationScheme);
|
||||
var context = new CookieValidatePrincipalContext(httpContext.Object, new AuthenticationSchemeBuilder(IdentityConstants.ApplicationScheme) { HandlerType = typeof(NoopHandler) }.Build(), ticket, new CookieAuthenticationOptions());
|
||||
Assert.NotNull(context.Properties);
|
||||
Assert.NotNull(context.Options);
|
||||
Assert.NotNull(context.Principal);
|
||||
|
|
@ -179,14 +182,15 @@ namespace Microsoft.AspNetCore.Identity.Test
|
|||
var user = new TestUser("test");
|
||||
var httpContext = new Mock<HttpContext>();
|
||||
var userManager = MockHelpers.MockUserManager<TestUser>();
|
||||
var identityOptions = new Mock<IOptions<IdentityOptions>>();
|
||||
identityOptions.Setup(a => a.Value).Returns(new IdentityOptions());
|
||||
var claimsManager = new Mock<IUserClaimsPrincipalFactory<TestUser>>();
|
||||
var identityOptions = new IdentityOptions { SecurityStampValidationInterval = TimeSpan.FromDays(1) };
|
||||
var options = new Mock<IOptions<IdentityOptions>>();
|
||||
options.Setup(a => a.Value).Returns(identityOptions);
|
||||
var options = new Mock<IOptions<SecurityStampValidatorOptions>>();
|
||||
options.Setup(a => a.Value).Returns(new SecurityStampValidatorOptions { ValidationInterval = TimeSpan.FromDays(1) });
|
||||
var contextAccessor = new Mock<IHttpContextAccessor>();
|
||||
contextAccessor.Setup(a => a.HttpContext).Returns(httpContext.Object);
|
||||
var signInManager = new Mock<SignInManager<TestUser>>(userManager.Object,
|
||||
contextAccessor.Object, claimsManager.Object, options.Object, null, new Mock<IAuthenticationSchemeProvider>().Object);
|
||||
contextAccessor.Object, claimsManager.Object, identityOptions.Object, null, new Mock<IAuthenticationSchemeProvider>().Object);
|
||||
signInManager.Setup(s => s.ValidateSecurityStampAsync(It.IsAny<ClaimsPrincipal>())).Throws(new Exception("Shouldn't be called"));
|
||||
signInManager.Setup(s => s.SignInAsync(user, false, null)).Throws(new Exception("Shouldn't be called"));
|
||||
var services = new ServiceCollection();
|
||||
|
|
@ -194,13 +198,13 @@ namespace Microsoft.AspNetCore.Identity.Test
|
|||
services.AddSingleton(signInManager.Object);
|
||||
services.AddSingleton<ISecurityStampValidator>(new SecurityStampValidator<TestUser>(options.Object, signInManager.Object, new SystemClock()));
|
||||
httpContext.Setup(c => c.RequestServices).Returns(services.BuildServiceProvider());
|
||||
var id = new ClaimsIdentity(identityOptions.Cookies.ApplicationCookieAuthenticationScheme);
|
||||
var id = new ClaimsIdentity(IdentityConstants.ApplicationScheme);
|
||||
id.AddClaim(new Claim(ClaimTypes.NameIdentifier, user.Id));
|
||||
|
||||
var ticket = new AuthenticationTicket(new ClaimsPrincipal(id),
|
||||
new AuthenticationProperties { IssuedUtc = DateTimeOffset.UtcNow },
|
||||
identityOptions.Cookies.ApplicationCookieAuthenticationScheme);
|
||||
var context = new CookieValidatePrincipalContext(httpContext.Object, new AuthenticationSchemeBuilder(identityOptions.Cookies.ApplicationCookieAuthenticationScheme) { HandlerType = typeof(NoopHandler) }.Build(), ticket, new CookieAuthenticationOptions());
|
||||
IdentityConstants.ApplicationScheme);
|
||||
var context = new CookieValidatePrincipalContext(httpContext.Object, new AuthenticationSchemeBuilder(IdentityConstants.ApplicationScheme) { HandlerType = typeof(NoopHandler) }.Build(), ticket, new CookieAuthenticationOptions());
|
||||
Assert.NotNull(context.Properties);
|
||||
Assert.NotNull(context.Options);
|
||||
Assert.NotNull(context.Principal);
|
||||
|
|
|
|||
|
|
@ -293,7 +293,7 @@ namespace Microsoft.AspNetCore.Identity.Test
|
|||
var context = new DefaultHttpContext();
|
||||
var helper = SetupSignInManager(manager.Object, context);
|
||||
var auth = MockAuth(context);
|
||||
auth.Setup(a => a.SignInAsync(context, helper.Options.Cookies.TwoFactorUserIdCookieAuthenticationScheme,
|
||||
auth.Setup(a => a.SignInAsync(context, IdentityConstants.TwoFactorUserIdScheme,
|
||||
It.Is<ClaimsPrincipal>(id => id.FindFirstValue(ClaimTypes.Name) == user.Id),
|
||||
It.IsAny<AuthenticationProperties>())).Returns(Task.FromResult(0)).Verifiable();
|
||||
|
||||
|
|
@ -337,7 +337,7 @@ namespace Microsoft.AspNetCore.Identity.Test
|
|||
}
|
||||
else
|
||||
{
|
||||
auth.Setup(a => a.SignInAsync(context, helper.Options.Cookies.TwoFactorUserIdCookieAuthenticationScheme,
|
||||
auth.Setup(a => a.SignInAsync(context, IdentityConstants.TwoFactorUserIdScheme,
|
||||
It.Is<ClaimsPrincipal>(id => id.FindFirstValue(ClaimTypes.Name) == user.Id),
|
||||
It.IsAny<AuthenticationProperties>())).Returns(Task.FromResult(0)).Verifiable();
|
||||
}
|
||||
|
|
@ -386,14 +386,14 @@ namespace Microsoft.AspNetCore.Identity.Test
|
|||
}
|
||||
var id = helper.StoreTwoFactorInfo(user.Id, null);
|
||||
SetupSignIn(context, auth, user.Id, isPersistent);
|
||||
auth.Setup(a => a.AuthenticateAsync(context, helper.Options.Cookies.TwoFactorUserIdCookieAuthenticationScheme))
|
||||
.ReturnsAsync(AuthenticateResult.Success(new AuthenticationTicket(id, null, helper.Options.Cookies.TwoFactorUserIdCookieAuthenticationScheme))).Verifiable();
|
||||
auth.Setup(a => a.AuthenticateAsync(context, IdentityConstants.TwoFactorUserIdScheme))
|
||||
.ReturnsAsync(AuthenticateResult.Success(new AuthenticationTicket(id, null, IdentityConstants.TwoFactorUserIdScheme))).Verifiable();
|
||||
if (rememberClient)
|
||||
{
|
||||
auth.Setup(a => a.SignInAsync(context,
|
||||
helper.Options.Cookies.TwoFactorRememberMeCookieAuthenticationScheme,
|
||||
IdentityConstants.TwoFactorRememberMeScheme,
|
||||
It.Is<ClaimsPrincipal>(i => i.FindFirstValue(ClaimTypes.Name) == user.Id
|
||||
&& i.Identities.First().AuthenticationType == helper.Options.Cookies.TwoFactorRememberMeCookieAuthenticationScheme),
|
||||
&& i.Identities.First().AuthenticationType == IdentityConstants.TwoFactorRememberMeScheme),
|
||||
It.IsAny<AuthenticationProperties>())).Returns(Task.FromResult(0)).Verifiable();
|
||||
}
|
||||
|
||||
|
|
@ -432,19 +432,19 @@ namespace Microsoft.AspNetCore.Identity.Test
|
|||
if (externalLogin)
|
||||
{
|
||||
auth.Setup(a => a.SignInAsync(context,
|
||||
helper.Options.Cookies.ApplicationCookieAuthenticationScheme,
|
||||
IdentityConstants.ApplicationScheme,
|
||||
It.Is<ClaimsPrincipal>(i => i.FindFirstValue(ClaimTypes.AuthenticationMethod) == loginProvider
|
||||
&& i.FindFirstValue(ClaimTypes.NameIdentifier) == user.Id),
|
||||
It.IsAny<AuthenticationProperties>())).Returns(Task.FromResult(0)).Verifiable();
|
||||
auth.Setup(a => a.SignOutAsync(context, helper.Options.Cookies.ExternalCookieAuthenticationScheme, It.IsAny<AuthenticationProperties>())).Returns(Task.FromResult(0)).Verifiable();
|
||||
auth.Setup(a => a.SignOutAsync(context, helper.Options.Cookies.TwoFactorUserIdCookieAuthenticationScheme, It.IsAny<AuthenticationProperties>())).Returns(Task.FromResult(0)).Verifiable();
|
||||
auth.Setup(a => a.SignOutAsync(context, IdentityConstants.ExternalScheme, It.IsAny<AuthenticationProperties>())).Returns(Task.FromResult(0)).Verifiable();
|
||||
auth.Setup(a => a.SignOutAsync(context, IdentityConstants.TwoFactorUserIdScheme, It.IsAny<AuthenticationProperties>())).Returns(Task.FromResult(0)).Verifiable();
|
||||
}
|
||||
else
|
||||
{
|
||||
SetupSignIn(context, auth, user.Id);
|
||||
}
|
||||
auth.Setup(a => a.AuthenticateAsync(context, helper.Options.Cookies.TwoFactorUserIdCookieAuthenticationScheme))
|
||||
.ReturnsAsync(AuthenticateResult.Success(new AuthenticationTicket(id, null, helper.Options.Cookies.TwoFactorUserIdCookieAuthenticationScheme))).Verifiable();
|
||||
auth.Setup(a => a.AuthenticateAsync(context, IdentityConstants.TwoFactorUserIdScheme))
|
||||
.ReturnsAsync(AuthenticateResult.Success(new AuthenticationTicket(id, null, IdentityConstants.TwoFactorUserIdScheme))).Verifiable();
|
||||
|
||||
// Act
|
||||
var result = await helper.TwoFactorRecoveryCodeSignInAsync(bypassCode);
|
||||
|
|
@ -508,7 +508,7 @@ namespace Microsoft.AspNetCore.Identity.Test
|
|||
// REVIEW: auth changes we lost the ability to mock is persistent
|
||||
//var properties = new AuthenticationProperties { IsPersistent = isPersistent };
|
||||
var authResult = AuthenticateResult.None();
|
||||
auth.Setup(a => a.AuthenticateAsync(context, new IdentityCookieOptions().ApplicationCookieAuthenticationScheme))
|
||||
auth.Setup(a => a.AuthenticateAsync(context, IdentityConstants.ApplicationScheme))
|
||||
.Returns(Task.FromResult(authResult)).Verifiable();
|
||||
var manager = SetupUserManager(user);
|
||||
var signInManager = new Mock<SignInManager<TestUser>>(manager.Object,
|
||||
|
|
@ -569,14 +569,14 @@ namespace Microsoft.AspNetCore.Identity.Test
|
|||
if (externalLogin)
|
||||
{
|
||||
auth.Setup(a => a.SignInAsync(context,
|
||||
helper.Options.Cookies.ApplicationCookieAuthenticationScheme,
|
||||
IdentityConstants.ApplicationScheme,
|
||||
It.Is<ClaimsPrincipal>(i => i.FindFirstValue(ClaimTypes.AuthenticationMethod) == loginProvider
|
||||
&& i.FindFirstValue(ClaimTypes.NameIdentifier) == user.Id),
|
||||
It.IsAny<AuthenticationProperties>())).Returns(Task.FromResult(0)).Verifiable();
|
||||
// REVIEW: restore ability to test is persistent
|
||||
//It.Is<AuthenticationProperties>(v => v.IsPersistent == isPersistent))).Verifiable();
|
||||
auth.Setup(a => a.SignOutAsync(context, helper.Options.Cookies.ExternalCookieAuthenticationScheme, It.IsAny<AuthenticationProperties>())).Returns(Task.FromResult(0)).Verifiable();
|
||||
auth.Setup(a => a.SignOutAsync(context, helper.Options.Cookies.TwoFactorUserIdCookieAuthenticationScheme, It.IsAny<AuthenticationProperties>())).Returns(Task.FromResult(0)).Verifiable();
|
||||
auth.Setup(a => a.SignOutAsync(context, IdentityConstants.ExternalScheme, It.IsAny<AuthenticationProperties>())).Returns(Task.FromResult(0)).Verifiable();
|
||||
auth.Setup(a => a.SignOutAsync(context, IdentityConstants.TwoFactorUserIdScheme, It.IsAny<AuthenticationProperties>())).Returns(Task.FromResult(0)).Verifiable();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -585,14 +585,14 @@ namespace Microsoft.AspNetCore.Identity.Test
|
|||
if (rememberClient)
|
||||
{
|
||||
auth.Setup(a => a.SignInAsync(context,
|
||||
helper.Options.Cookies.TwoFactorRememberMeCookieAuthenticationScheme,
|
||||
IdentityConstants.TwoFactorRememberMeScheme,
|
||||
It.Is<ClaimsPrincipal>(i => i.FindFirstValue(ClaimTypes.Name) == user.Id
|
||||
&& i.Identities.First().AuthenticationType == helper.Options.Cookies.TwoFactorRememberMeCookieAuthenticationScheme),
|
||||
&& i.Identities.First().AuthenticationType == IdentityConstants.TwoFactorRememberMeScheme),
|
||||
It.IsAny<AuthenticationProperties>())).Returns(Task.FromResult(0)).Verifiable();
|
||||
//It.Is<AuthenticationProperties>(v => v.IsPersistent == true))).Returns(Task.FromResult(0)).Verifiable();
|
||||
}
|
||||
auth.Setup(a => a.AuthenticateAsync(context, helper.Options.Cookies.TwoFactorUserIdCookieAuthenticationScheme))
|
||||
.ReturnsAsync(AuthenticateResult.Success(new AuthenticationTicket(id, null, helper.Options.Cookies.TwoFactorUserIdCookieAuthenticationScheme))).Verifiable();
|
||||
auth.Setup(a => a.AuthenticateAsync(context, IdentityConstants.TwoFactorUserIdScheme))
|
||||
.ReturnsAsync(AuthenticateResult.Success(new AuthenticationTicket(id, null, IdentityConstants.TwoFactorUserIdScheme))).Verifiable();
|
||||
|
||||
// Act
|
||||
var result = await helper.TwoFactorSignInAsync(provider, code, isPersistent, rememberClient);
|
||||
|
|
@ -614,9 +614,9 @@ namespace Microsoft.AspNetCore.Identity.Test
|
|||
var helper = SetupSignInManager(manager.Object, context);
|
||||
auth.Setup(a => a.SignInAsync(
|
||||
context,
|
||||
manager.Object.Options.Cookies.TwoFactorRememberMeCookieAuthenticationScheme,
|
||||
IdentityConstants.TwoFactorRememberMeScheme,
|
||||
It.Is<ClaimsPrincipal>(i => i.FindFirstValue(ClaimTypes.Name) == user.Id
|
||||
&& i.Identities.First().AuthenticationType == manager.Object.Options.Cookies.TwoFactorRememberMeCookieAuthenticationScheme),
|
||||
&& i.Identities.First().AuthenticationType == IdentityConstants.TwoFactorRememberMeScheme),
|
||||
It.Is<AuthenticationProperties>(v => v.IsPersistent == true))).Returns(Task.FromResult(0)).Verifiable();
|
||||
|
||||
|
||||
|
|
@ -647,10 +647,10 @@ namespace Microsoft.AspNetCore.Identity.Test
|
|||
var context = new DefaultHttpContext();
|
||||
var auth = MockAuth(context);
|
||||
SetupSignIn(context, auth);
|
||||
var id = new ClaimsIdentity(manager.Object.Options.Cookies.TwoFactorRememberMeCookieAuthenticationScheme);
|
||||
var id = new ClaimsIdentity(IdentityConstants.TwoFactorRememberMeScheme);
|
||||
id.AddClaim(new Claim(ClaimTypes.Name, user.Id));
|
||||
auth.Setup(a => a.AuthenticateAsync(context, manager.Object.Options.Cookies.TwoFactorRememberMeCookieAuthenticationScheme))
|
||||
.ReturnsAsync(AuthenticateResult.Success(new AuthenticationTicket(new ClaimsPrincipal(id), null, manager.Object.Options.Cookies.TwoFactorRememberMeCookieAuthenticationScheme))).Verifiable();
|
||||
auth.Setup(a => a.AuthenticateAsync(context, IdentityConstants.TwoFactorRememberMeScheme))
|
||||
.ReturnsAsync(AuthenticateResult.Success(new AuthenticationTicket(new ClaimsPrincipal(id), null, IdentityConstants.TwoFactorRememberMeScheme))).Verifiable();
|
||||
var helper = SetupSignInManager(manager.Object, context);
|
||||
|
||||
// Act
|
||||
|
|
@ -669,19 +669,16 @@ namespace Microsoft.AspNetCore.Identity.Test
|
|||
return auth;
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("Microsoft.AspNetCore.Identity.Authentication.Application")]
|
||||
[InlineData("Foo")]
|
||||
public async Task SignOutCallsContextResponseSignOut(string authenticationScheme)
|
||||
[Fact]
|
||||
public async Task SignOutCallsContextResponseSignOut()
|
||||
{
|
||||
// Setup
|
||||
var manager = MockHelpers.TestUserManager<TestUser>();
|
||||
manager.Options.Cookies.ApplicationCookieAuthenticationScheme = authenticationScheme;
|
||||
var context = new DefaultHttpContext();
|
||||
var auth = MockAuth(context);
|
||||
auth.Setup(a => a.SignOutAsync(context, authenticationScheme, It.IsAny<AuthenticationProperties>())).Returns(Task.FromResult(0)).Verifiable();
|
||||
auth.Setup(a => a.SignOutAsync(context, manager.Options.Cookies.TwoFactorUserIdCookieAuthenticationScheme, It.IsAny<AuthenticationProperties>())).Returns(Task.FromResult(0)).Verifiable();
|
||||
auth.Setup(a => a.SignOutAsync(context, manager.Options.Cookies.ExternalCookieAuthenticationScheme, It.IsAny<AuthenticationProperties>())).Returns(Task.FromResult(0)).Verifiable();
|
||||
auth.Setup(a => a.SignOutAsync(context, IdentityConstants.ApplicationScheme, It.IsAny<AuthenticationProperties>())).Returns(Task.FromResult(0)).Verifiable();
|
||||
auth.Setup(a => a.SignOutAsync(context, IdentityConstants.TwoFactorUserIdScheme, It.IsAny<AuthenticationProperties>())).Returns(Task.FromResult(0)).Verifiable();
|
||||
auth.Setup(a => a.SignOutAsync(context, IdentityConstants.ExternalScheme, It.IsAny<AuthenticationProperties>())).Returns(Task.FromResult(0)).Verifiable();
|
||||
var helper = SetupSignInManager(manager, context, null, manager.Options);
|
||||
|
||||
// Act
|
||||
|
|
@ -828,7 +825,7 @@ namespace Microsoft.AspNetCore.Identity.Test
|
|||
private static void SetupSignIn(HttpContext context, Mock<IAuthenticationService> auth, string userId = null, bool? isPersistent = null, string loginProvider = null)
|
||||
{
|
||||
auth.Setup(a => a.SignInAsync(context,
|
||||
new IdentityCookieOptions().ApplicationCookieAuthenticationScheme,
|
||||
IdentityConstants.ApplicationScheme,
|
||||
It.Is<ClaimsPrincipal>(id =>
|
||||
(userId == null || id.FindFirstValue(ClaimTypes.NameIdentifier) == userId) &&
|
||||
(loginProvider == null || id.FindFirstValue(ClaimTypes.AuthenticationMethod) == loginProvider)),
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ namespace Microsoft.AspNetCore.Identity.Test
|
|||
var manager = userManager.Object;
|
||||
Assert.NotNull(identity);
|
||||
Assert.Equal(1, principal.Identities.Count());
|
||||
Assert.Equal(identityOptions.Cookies.ApplicationCookieAuthenticationScheme, identity.AuthenticationType);
|
||||
Assert.Equal(IdentityConstants.ApplicationScheme, identity.AuthenticationType);
|
||||
var claims = identity.Claims.ToList();
|
||||
Assert.NotNull(claims);
|
||||
Assert.True(
|
||||
|
|
|
|||
|
|
@ -5,8 +5,6 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
|
|
@ -31,7 +29,6 @@ namespace Microsoft.AspNetCore.Identity.Test
|
|||
services.AddLogging();
|
||||
var manager = services.BuildServiceProvider().GetRequiredService<UserManager<TestUser>>();
|
||||
Assert.NotNull(manager.PasswordHasher);
|
||||
Assert.NotNull(manager.Store);
|
||||
Assert.NotNull(manager.Options);
|
||||
}
|
||||
|
||||
|
|
@ -64,7 +61,7 @@ namespace Microsoft.AspNetCore.Identity.Test
|
|||
|
||||
public class CustomRoleManager : RoleManager<TestRole>
|
||||
{
|
||||
public CustomRoleManager() : base(new Mock<IRoleStore<TestRole>>().Object, null, null, null, null, null)
|
||||
public CustomRoleManager() : base(new Mock<IRoleStore<TestRole>>().Object, null, null, null, null)
|
||||
{ }
|
||||
}
|
||||
|
||||
|
|
@ -639,9 +636,9 @@ namespace Microsoft.AspNetCore.Identity.Test
|
|||
await Assert.ThrowsAsync<NotSupportedException>(() => manager.UpdateSecurityStampAsync(null));
|
||||
await Assert.ThrowsAsync<NotSupportedException>(() => manager.GetSecurityStampAsync(null));
|
||||
await Assert.ThrowsAsync<NotSupportedException>(
|
||||
() => manager.VerifyChangePhoneNumberTokenAsync(null, "1", "111-111-1111"));
|
||||
() => manager.VerifyChangePhoneNumberTokenAsync(new TestUser(), "1", "111-111-1111"));
|
||||
await Assert.ThrowsAsync<NotSupportedException>(
|
||||
() => manager.GenerateChangePhoneNumberTokenAsync(null, "111-111-1111"));
|
||||
() => manager.GenerateChangePhoneNumberTokenAsync(new TestUser(), "111-111-1111"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
|
@ -30,7 +30,8 @@ namespace Microsoft.AspNetCore.Identity.Test
|
|||
store = store ?? new Mock<IRoleStore<TRole>>().Object;
|
||||
var roles = new List<IRoleValidator<TRole>>();
|
||||
roles.Add(new RoleValidator<TRole>());
|
||||
return new Mock<RoleManager<TRole>>(store, roles, null, null, null, null);
|
||||
return new Mock<RoleManager<TRole>>(store, roles, new UpperInvariantLookupNormalizer(),
|
||||
new IdentityErrorDescriber(), null);
|
||||
}
|
||||
|
||||
public static Mock<ILogger<T>> MockILogger<T>(StringBuilder logStore = null) where T : class
|
||||
|
|
@ -88,7 +89,7 @@ namespace Microsoft.AspNetCore.Identity.Test
|
|||
store = store ?? new Mock<IRoleStore<TRole>>().Object;
|
||||
var roles = new List<IRoleValidator<TRole>>();
|
||||
roles.Add(new RoleValidator<TRole>());
|
||||
return new RoleManager<TRole>(store, roles,
|
||||
return new AspNetRoleManager<TRole>(store, roles,
|
||||
new UpperInvariantLookupNormalizer(),
|
||||
new IdentityErrorDescriber(),
|
||||
null,
|
||||
|
|
|
|||
Loading…
Reference in New Issue