Cookie过期OWIN

时间:2015-07-09 19:16:54

标签: asp.net-mvc cookies owin

我最近注意到以下Cookie的发布时间为1年:

__ RequestVerificationToken .AspNet.Cookies .openidconnect.nonce。[GUID]

如果我添加以下代码,.AspNet.Cookies将有所需的15分钟到期时间:

CookieAuthenticationOptions cookieAuthenticationOptions = new CookieAuthenticationOptions()
{
    Provider = new CookieAuthenticationProvider
    {
        OnResponseSignIn = (CookieResponseSignInContext context) =>
        {
            context.CookieOptions.Expires = DateTime.UtcNow.AddMinutes(15);
        }
    }
};

app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
app.UseCookieAuthentication(cookieAuthenticationOptions);
app.UseOpenIdConnectAuthentication(openIdConnectAuthenticationOptions);
app.UseWindowsAzureActiveDirectoryBearerAuthentication(windowsAzureActiveDirectoryBearerAuthenticationOptions);

但我无法弄清楚如何为其他Cookie设置类似的到期时间?

0 个答案:

没有答案