bck*_*rld 12 authentication asp.net-mvc-5 asp.net-identity
通过设置AuthenticationProperties.IsPersistent为true,我们使身份验证cookie保持不变,因此用户在开始新会话时不必再次进行身份验证
CookieAuthenticationOptions.ExpireTimeSpans 控制cookie的有效期.
AuthenticationProperties.ExpiresUtc 设置身份验证的到期日期
a)我不确定" 认证的到期日期 " 是什么意思.也许上面的引用说ExpiresUtc控制用户再次被要求登录之前可以使用身份验证cookie进行身份验证多长时间?
b)如果我在a)中的假设是正确的,那么当ExpireUtc达到时,即使以下情况,cookie也将过期:
IsPersistent == true 和
会话尚未到期
cookie还没有超过设定的寿命ExpireTimeSpan?
c)如果IsPersistent设置为false,则会话到期后,即使以下情况,cookie也不再有效:
cookie尚未超过ExpireTimeSpan和设置的生命周期
身份验证尚未达到设定的生命周期ExpireUtc?
d)当cookie超过ExpireTimeSpan设置的生命周期时,即使以下情况,cookie也不再有效:
IsPersistent == true 和
会话尚未到期
身份验证尚未达到设定的生命周期ExpireUtc?
谢谢
Rah*_*arg -1
对于 Identity Framework,有一个属性 ExpireTimeSpan,它表明 cookie 的生命周期。根据下面的示例,cookie 将在 24 小时后失效。
public static void ConfigureOAuthSettings(IAppBuilder app)
{
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
SlidingExpiration = false,
ExpireTimeSpan = TimeSpan.FromHours(24)
});}
Run Code Online (Sandbox Code Playgroud)
如果您想获得更详细的代码,请访问这里
| 归档时间: |
|
| 查看次数: |
852 次 |
| 最近记录: |