如何解决更新到IdentityServer4 3.1.3后,AccessToken确实会错过关键受众
我们已经使用IdentityServer4实现了Identity-Provider。最近,我们将应用程序升级到.net core 3.1(从2.1),并通过它将IdentityServer4-Nuget-Packages从版本2.2.0升级到了3.1.3。
这些是旧状态(使用.net 2.1和IdentityServer4 2.2.0提供)的访问令牌的实际内容
{
"nbf": 1597236398,"exp": 1597239998,"iss": "https://lab10vm-tri-2:8777/usermgmt/identityprovider","aud": [
"https://lab10vm-tri-2:8777/usermgmt/identityprovider/resources","basecommon"
],"client_id": "Webportal","sub": "d860efca-22d9-47fd-8249-791ba61b07c7","auth_time": 1597236392,"idp": "local","upn": "Administrator","scope": [
"openid","profile","amr": [
"pwd"
]
}
以下是新状态(.net 3.1和IdentityServer4 3.1.3)提供的访问令牌的内容:
{
"nbf": 1597236389,"exp": 1597239989,"iss": "https://lab10vm-tri-3:8777/usermgmt/identityprovider","aud": "basecommon","auth_time": 1597236383,"amr": [
"pwd"
]
}
如您所见,旧版本包含一个称为“ https:// lab10vm-tri-2:8777 / usermgmt / identityprovider / resources”的受众,而新版本则没有。
请告诉我:如何恢复以前的行为,以便吸引观众?
我尝试过的方法:Google非常非常喜欢诸如“ IdentityServer 3.1听众丢失”之类的话题。 我以这种方式发现的所有结果都与我的情况不符,而且我也不知道要看哪里了。
解决方法
尝试升级到IdentityServer 4的4.0x版本,请在最新版本中重新考虑。因为我在3.13版本中没有看到它,但是我看到它出现在v4.0.0中
,设置IdentityServer4时需要设置options.EmitLegacyResourceAudienceClaim = true;
,默认值为false。
它发出aud
格式的issuer/resources
声明
这是您的代码的外观:
namespace IdentityServer
{
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
var builder = services.AddIdentityServer(
options =>
{
options.EmitLegacyResourceAudienceClaim = true; //Default value is false
})
.AddInMemoryIdentityResources(Config.Ids)
.AddInMemoryApiResources(Config.Apis)
.AddInMemoryClients(Config.Clients)
.AddTestUsers(TestUsers.Users);
}
}
}
详细了解EmitLegacyResourceAudienceClaim
here
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。