我最近注意到以下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设置类似的到期时间?