我无法理解 JWT 令牌的生命周期。
= 120 / 60 = 2 分钟
IdentityTokenLifetime
的目的是什么?
= 120 / 60 = 2 分钟
= 300 / 60 = 5 分钟
从奇怪的摘要评论信息来看,我真的不明白 JWT 令牌在几分钟内存活了多久。
public static IEnumerable<Client> GetClients(IConfiguration configuration) =>
new List<Client>
{
new()
{
ClientName = configuration["AuthConfiguration:ClientName"],
ClientId = configuration["AuthConfiguration:ClientId"],
ClientSecrets = { new Secret(configuration["AuthConfiguration:ClientSecret"].Sha256()) },
AllowedGrantTypes = GrantTypes.ResourceOwnerPasswordAndClientCredentials,
AccessTokenType = AccessTokenType.Jwt,
AllowOfflineAccess = true,
AccessTokenLifetime = 120,
IdentityTokenLifetime = 120,
UpdateAccessTokenClaimsOnRefresh = true,
SlidingRefreshTokenLifetime = 300,
RefreshTokenExpiration = TokenExpiration.Absolute,
RefreshTokenUsage = TokenUsage.OneTimeOnly,
AlwaysSendClientClaims = true,
AllowedScopes =
{
IdentityServerConstants.StandardScopes.OpenId,
IdentityServerConstants.StandardScopes.Profile,
IdentityServerConstants.StandardScopes.OfflineAccess,
configuration["AuthConfiguration:ApiName"]
}
}
};
答案 0 :(得分:1)
根据您的示例,身份验证成功后,将创建以下令牌:
要获得以分钟为单位的每个令牌的生命周期,将秒除以 60。