zer*_*roG 3 authentication cookies identity asp.net-identity asp.net-core
对于基于 cookie 的身份验证,这两种 cookie 配置有什么区别?
public void ConfigureServices(IServiceCollection services)
{
services.AddControllersWithViews();
// Configure cookie based authentication:
services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
.AddCookie(opt =>
{
/* validation rules */
});
}
Run Code Online (Sandbox Code Playgroud)
public void ConfigureServices(IServiceCollection services)
{
services.AddIdentity<AppUser, AppRole>(opt =>
{
/* validation rules */
});
services.ConfigureApplicationCookie(options =>
{
options.LoginPath = new PathString("/User/Login");
options.Cookie = new CookieBuilder
{
Name = "AspNetCoreIdentityExampleCookie",
HttpOnly = false,
SameSite = SameSiteMode.Lax,
SecurePolicy = CookieSecurePolicy.Always
};
options.ExpireTimeSpan = TimeSpan.FromMinutes(2);
options.SlidingExpiration = true;
});
}
Run Code Online (Sandbox Code Playgroud)
我无法理解其中的区别,我会很高兴听到任何帮助。
归档时间: |
|
查看次数: |
596 次 |
最近记录: |