Rak*_*mar 5 c# .net-core identityserver4
我们使用的是 Identity Server4,默认时间是访问令牌过期时间是 3600 秒。我们可以设置它不过期吗?
public static IEnumerable<Client> GetClients()
{
return new List<Client>
{
new Client
{
ClientId = "client",
// no interactive user, use the clientid/secret for authentication
AllowedGrantTypes = GrantTypes.ClientCredentials,
// secret for authentication
ClientSecrets =
{
new Secret("secret".Sha256())
},
// scopes that client has access to
AllowedScopes = { "api1" },
AccessTokenLifetime=3600
}
};
Run Code Online (Sandbox Code Playgroud)
从技术上讲 AccessTokenLifetime 被声明为 int 所以你可以这样做
AccessTokenLifetime = Int32.MaxValue;
Run Code Online (Sandbox Code Playgroud)
但这确实不是一个好主意。一旦创建了访问令牌,它就会继续工作,我认为您在支持中使其过期不会像您希望的那样工作。
为了它的乐趣
TimeSpan t = TimeSpan.FromSeconds(Int32.MaxValue);
Console.WriteLine(t.Days);
Run Code Online (Sandbox Code Playgroud)
结果是非常丑陋的 24855 天或 68 年。
| 归档时间: |
|
| 查看次数: |
2264 次 |
| 最近记录: |