更新System.IdentityModel.Tokens.Jwt导致IdentityServer3客户端发生重大更改
希望很容易解决。
微软的System.IdentityModels.Tokens.Jwt
软件包昨天在NuGet上从4.0.2.206211351
更新到v5.0
。 遗憾的是,这会导致一些“标准” IdentityServer3
代码发生重大变化。 即从他们的代码示例中提取,所以我想很多开发人员可能会在未来几天看到这个问题。
原始代码
使用v4.0.2.xxxxxx版本的软件包。 我有
using System.IdentityModel.Tokens;
在命名空间中。
然后在Configuration方法中开始如下:
public void Configuration(IAppBuilder app) { AntiForgeryConfig.UniqueClaimTypeIdentifier = "sub"; JwtSecurityTokenHandler.InboundClaimTypeMap = new Dictionary(); app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationType = "Cookies" }); app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions { ... };
更新后
更新配置行后:
JwtSecurityTokenHandler.InboundClaimTypeMap = new Dictionary();
造成问题。
第一件事是,Class显然已经移入System.IdentityModel.Tokens.Jwt
命名空间,这个解决起来并不是那么糟糕。
但是,我现在正在获取JwtSecurityTokenHandler.InboundClaimTypeMap
上的Object reference required for a non-static field
错误Object reference required for a non-static field
的Object reference required for a non-static field
。
我是否在这里遗漏了一些东西,另一个需要的库或者在调用Startup.Configuration()
之前发生了什么事需要深入研究?
当你去看医生说“当我这样做时总是疼” – 医生会回复“然后停止这样做”;)
v4 – > v5根据定义是一个重大变化。 你需要v5吗?
话虽这么说 – 一个简单的智能感知探索会带来他们将InboundClaimTypeMap
重InboundClaimTypeMap
为DefaultInboundClaimTypeMap
。
随时准备好迎接更多重大变革。
OWIN中的访问令牌validation与system.identitymodel v5不兼容 – 您需要降级到v4 – 请参阅此处的问题