希望是一个容易解决的问题。
Microsoft 的 System.IdentityModels.Tokens.Jwt
包昨天在 NuGet 上从 4.0.2.206211351
更新到 v5.0
。不幸的是,这导致了一些“标准”IdentityServer3
代码的重大变化。即取自他们的代码示例,所以我想在未来几天可能会有相当多的开发人员看到这个问题。
原始代码
使用v4.0.2.xxxxxx版本的包。我有
using System.IdentityModel.Tokens;
在命名空间中。
然后在配置方法中开始为:
public void Configuration(IAppBuilder app)
{
AntiForgeryConfig.UniqueClaimTypeIdentifier = "sub";
JwtSecurityTokenHandler.InboundClaimTypeMap = new Dictionary<string, string>();
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = "Cookies"
});
app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions
{ ... };
更新后
更新配置行后:
JwtSecurityTokenHandler.InboundClaimTypeMap = new Dictionary<string, string>();
导致问题。
首先是该类显然已移入 System.IdentityModel.Tokens.Jwt
命名空间,这并不难解决。
但是,我现在在 JwtSecurityTokenHandler.InboundClaimTypeMap
上收到 Object reference required for a non-static field
错误。
我是不是遗漏了什么,另一个库是必需的,还是在调用 Startup.Configuration()
之前发生了什么需要深入研究?
最佳答案
当你去看医生并说“我这样做时总是很痛”——医生会回答“那就停止这样做”;)
v4 -> v5 根据定义是一个重大变化。您需要 v5 吗?
话虽如此 - 一个简单的智能感知探索会发现他们将 InboundClaimTypeMap
重命名为 DefaultInboundClaimTypeMap
。
为沿途的更多重大变化做好准备。
关于c# - System.IdentityModel.Tokens.Jwt 的更新导致 IdentityServer3 客户端发生重大变化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38080608/