identityserver4 - IdentityServer4:将过期日期设置为“idsrv.session”cookie
问题描述
我的 Angular 应用程序的静默刷新机制出现问题,因为身份服务器无法正确设置 cookie 过期时间。
成功登录后,将为身份服务器的域设置以下 cookie:
正如您在图片中看到的,“idsrv.session”cookie 具有到期“会话”。在我的旧 IdentityServer3 中,此 cookie 具有正确的到期日期,并且一切正常。
谁能帮我解决这个问题。我需要一种方法来为“idsrv.session”cookie 设置过期日期。
以下是我为实现目标而添加的当前配置/语句:
// Startup.cs - ConfigureServices()
services
.AddIdentityServer(options =>
{
options.EmitStaticAudienceClaim = true;
options.AccessTokenJwtType = "JWT";
options.Authentication.CookieLifetime = TimeSpan.FromDays(30);
})
services
.AddAuthentication("Cookies")
.AddCookie("Cookies", options =>
{
options.ExpireTimeSpan = TimeSpan.FromDays(30);
})
// AccountController.cs - Login()
await HttpContext.SignInAsync(isuser, new AuthenticationProperties
{
IsPersistent = true,
ExpiresUtc = DateTimeOffset.UtcNow.Add(TimeSpan.FromDays(30))
});
但此设置对“idsrv.session”cookie 没有影响。
我使用 .net core 3.1 和 IdentityServer4 4.0.4。
谢谢!!
解决方案:
就我而言,以下语句对我有帮助,即用户不会在 30 分钟后注销。过期“idsrv.session”cookie 虽然仍设置为会话,但在 30 分钟后不会删除。
services.Configure<SecurityStampValidatorOptions>(o => o.ValidationInterval = TimeSpan.FromDays(30));
解决方案
推荐阅读
- javascript - 当它们具有不同的变换时,有没有办法从一个 SVG 的坐标转换到另一个
- java - GET /WEB-INF/jsp/login.jsp 没有映射
- performance - jmeter,为什么总是收到状态警告
- node.js - 如何根据 URL 参数从 mongo db 中查询
- swift - UIPIckerView - 具有可用插槽的 TimePicker
- cygwin - 用cygwin重新安装openssh
- java - 有没有办法将通过会话获取的数据库中的双值转换为字符串?
- r - 修改 y 轴标签的除最后一个元素之外的所有元素
- c# - WPF 将自定义 ContextMenu 添加到另一个视图中引用的视图
- json - 使用jq如何将key添加到现有的JSON数据结构中