【发布时间】:2020-07-22 22:44:40
【问题描述】:
我正在尝试为 OIDC cookie 设置过期日期。我尝试在Notifications.SecurityTokenValidated 中设置AuthenticationTicket.ExpiresUtc,但.AspNet.Cookies cookie 过期时间在浏览器中仍然是“会话”。有没有办法做到这一点?
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = CookieAuthenticationDefaults.AuthenticationType,
CookieHttpOnly = true
});
var oidcOptions = new OpenIdConnectAuthenticationOptions
{
UseTokenLifetime = false,
..
SignInAsAuthenticationType = CookieAuthenticationDefaults.AuthenticationType,
Notifications = new OpenIdConnectAuthenticationNotifications
{
SecurityTokenReceived = n =>
{
n.AuthenticationTicket.Properties.ExpiresUtc = System.DateTimeOffset.UtcNow.AddMinutes(30);
return Task.FromResult(0);
}
};
我正在使用 ASP.NET MVC .NET 4.5.2、Owin 4.0.1
【问题讨论】:
标签: c# asp.net asp.net-mvc owin openid-connect