如何在 Identity Server 4 中使用 typ: jwt 而不是 at+jwt 来颁发令牌?
How to issue tokens with typ: jwt instead of at+jwt in Identity Server 4?
Identity Server 4 与 Identity Server 3 不同,它使用默认值 "typ": "at+jwt"
颁发令牌,但是我仍然需要颁发旧版本的令牌,这意味着 "typ": "jwt"
。
有什么方法可以覆盖 IS4 的默认配置并发布 "typ": "jwt"
的 JWT 令牌吗?
我猜你只需要将这个 IdentityServer 选项设置为 jwt:
/// <summary>
/// Gets or sets the value for the JWT typ header for access tokens.
/// </summary>
/// <value>
/// The JWT typ value.
/// </value>
public string AccessTokenJwtType { get; set; } = "at+jwt";
查看源代码here:
只需更改 AddIdentityServer
上的 AccessTokenJwtType
:
var builder = services.AddIdentityServer(options =>
{
// see https://identityserver4.readthedocs.io/en/latest/topics/resources.html
options.EmitStaticAudienceClaim = true;
options.AccessTokenJwtType = "JWT";
})
这里我也在my blog post里解释了
Identity Server 4 与 Identity Server 3 不同,它使用默认值 "typ": "at+jwt"
颁发令牌,但是我仍然需要颁发旧版本的令牌,这意味着 "typ": "jwt"
。
有什么方法可以覆盖 IS4 的默认配置并发布 "typ": "jwt"
的 JWT 令牌吗?
我猜你只需要将这个 IdentityServer 选项设置为 jwt:
/// <summary>
/// Gets or sets the value for the JWT typ header for access tokens.
/// </summary>
/// <value>
/// The JWT typ value.
/// </value>
public string AccessTokenJwtType { get; set; } = "at+jwt";
查看源代码here:
只需更改 AddIdentityServer
上的 AccessTokenJwtType
:
var builder = services.AddIdentityServer(options =>
{
// see https://identityserver4.readthedocs.io/en/latest/topics/resources.html
options.EmitStaticAudienceClaim = true;
options.AccessTokenJwtType = "JWT";
})
这里我也在my blog post里解释了