【发布时间】:2021-12-02 14:24:43
【问题描述】:
我们刚刚将 Web 应用程序升级到 .NET 5,将 IdentityServer4 升级到 V4,我们也从混合流切换到代码 + PKCE。客户端设置为访问令牌类型的引用,客户端也将不记名令牌用于内部 API 以及用于主网站的 cookie。
当我们随机部署到内部开发服务器 (IIS 8.5) 或 Azure 应用服务时,当我们请求访问令牌(参考)时,我们会返回一个访问令牌 (JWT)。我们确实使用了 httpContext.GetTokenAsync() 方法,但随后将其替换为 identitymodel.aspnetcore GetUserAccessTokenAsync() 方法,但它仍然返回 JWT Token。
我已验证 JWT 令牌内容,它们是相关用户及其声明。我还检查了持久授权表,其中输入的参考令牌将其指定为 JWT 而不是参考。
纠正这种情况的唯一方法是
- 停止网站和身份服务器
- 清除浏览器中的cookies
- 删除持久授权表中的所有条目
- 回收应用程序池
- 启动身份服务器,然后执行登录
- 启动登录的网站,突然我们又得到一个参考访问令牌
身份服务器客户端配置
AllowedGrantTypes =
{
GrantType.AuthorizationCode,
"exchange_reference_token"
},
AccessTokenType = AccessTokenType.Reference,
AccessTokenLifetime = 86400,
RequireConsent = false,
AllowAccessTokensViaBrowser = true,
ClientSecrets =
{
new Secret("*******)
},
RedirectUris = { $"{client}/signin-oidc" },
PostLogoutRedirectUris = { $"{client}/signout-callback-oidc" },
FrontChannelLogoutUri = $"{client}/signout-oidc",
AllowedCorsOrigins = { client },
AllowedScopes =
{
IdentityServerConstants.StandardScopes.OpenId,
IdentityServerConstants.StandardScopes.Profile,
"roles",
"API1",
"API2",
"API3",
"Signalr"
},
UpdateAccessTokenClaimsOnRefresh = true,
AllowOfflineAccess = true
【问题讨论】:
标签: c# asp.net-core identityserver4