security - 如何在 openiddict 中设置 expires_in
问题描述
我想在 asp.net core 2.2 服务器上使用 openiddict 2.0.1 使用 oauth,有效期为一天,此时我可以使用刷新令牌(尽管我也会在之前检查未经授权的访问问题到期)。但是,我无法弄清楚如何设置到期时间。我总是将 expires_in 返回为 3600。
这是我在服务器上的 startup.cs 中所做的:
// Allow client applications to use the grant_type=password flow.
options.AllowPasswordFlow();
// and refreshing
options.AllowRefreshTokenFlow();
options.SetAccessTokenLifetime(TimeSpan.FromDays(1));
options.SetRefreshTokenLifetime(TimeSpan.FromDays(14));
然后在我的授权上下文(令牌处理程序)中:
// Create a new authentication ticket for the user's principal
var ticket = new AuthenticationTicket(
principal,
new AuthenticationProperties()
{
ExpiresUtc = DateTimeOffset.UtcNow.AddDays(1),
IsPersistent = true
},
OpenIdConnectServerDefaults.AuthenticationScheme);
[...]
// Sign in the user
return SignIn(ticket.Principal, ticket.Properties, ticket.AuthenticationScheme);
返回值已将 expires_in 设置为 3600 - 即:1 小时。但这似乎不是我设定的。expires_at 没有任何声明,这似乎是源代码用来生成 3600 的内容(甚至不确定如何设置它?)。
如何确保令牌在 1 天而不是 1 小时内过期?
谢谢,斯特凡
解决方案
推荐阅读
- docker - Testcontainers 无法在 Docker 中获取 Jenkins kubernates docker 上的映射端口
- mongodb - MongoDB 查询 - 数组中的元素 $condition
- c# - TikaOnDotNet - 无法提取文本文件内容
- javascript - 在同一画布上绘制两个图像并使其在角度应用程序中响应
- javascript - discord.js(12) 命令权限问题
- java - javax 无法将套接字转换为 TLS;
- serialization - Godot/Gdscript:为什么 str2var 不能使用 _init 方法处理类?
- python - 如何找到两个熊猫数据框之间的交集
- javascript - 可以在 sys_properties 中使用占位符吗?
- angular - 如何封装组件(工具栏)内容以防止组件(工具栏)成为单体?