【发布时间】:2019-04-22 07:17:53
【问题描述】:
我正在使用带有 IdentityServer3.AccessTokenValidation 和 Identity Server 4 的 MVC 客户端作为我的 IDP 应用程序。
我在下面的地方添加了 cookie 超时,但是似乎会话永远不会过期并且不会自动注销用户 -
在 MVC 客户端中 -
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = "Cookies",
ExpireTimeSpan = new TimeSpan(0, 20, 0, 0)
});
如果我设置的时间小于 20 小时,授权请求将无限循环运行
在 IDP 应用中,
services.AddIdentityServer(
opt => new IdentityServer4.Configuration.IdentityServerOptions
{
Authentication = new IdentityServer4.Configuration.AuthenticationOptions()
{
CookieLifetime = TimeSpan.FromSeconds(60)
}
}
在 IDP 应用中,
.AddCookie("Cookies", opt => {
opt.ExpireTimeSpan = TimeSpan.FromSeconds(60);
opt.Cookie = new CookieBuilder() { Expiration = new TimeSpan(0,0,0,60) };
opt.Events.OnSigningIn = (context) =>
{
context.CookieOptions.Expires = DateTimeOffset.UtcNow.AddSeconds(60);
return Task.CompletedTask;
};
})
【问题讨论】:
-
客户端当前的身份验证情况如何?
-
@ravneet 我也被困在实现会话超时。它只是不适合我。我不知道为什么。
标签: c# asp.net-mvc .net-core identityserver4 session-management