Closed daisukenishino2 closed 4 years ago
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
Provider = new CookieAuthenticationProvider
{
OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser>(
// SecurityStampValidatorによる検証の間隔
validateInterval: Config.SecurityStampValidateIntervalFromSeconds,
// ClaimsIdentityを返すdelegate
regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
},
ExpireTimeSpan = TimeSpan.FromMinutes(30)
});
↓ ↓ ↓
services.AddScoped<ISecurityStampValidator, SecurityStampValidator<IdentityUser>>();
services.Configure<SecurityStampValidatorOptions>(options =>
{
options.ValidationInterval = TimeSpan.FromSeconds(10);
});
AuthenticationBuilder authenticationBuilder = services.AddAuthentication();
authenticationBuilder.AddCookie(options =>
{
...
options.Events = new CookieAuthenticationEvents()
{
OnValidatePrincipal = SecurityStampValidator.ValidatePrincipalAsync
};
});
Requirement