System.IdentityModel.Tokens.Jwt的更新导致IdentityServer3 Client中的重大更改

编程入门 行业动态 更新时间:2024-10-21 15:27:47
本文介绍了System.IdentityModel.Tokens.Jwt的更新导致IdentityServer3 Client中的重大更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

希望这是一个易于解决的问题.

Hopefully an easy one to resolve.

Microsoft的System.IdentityModels.Tokens.Jwt包昨天在NuGet上从4.0.2.206211351更新到了v5.0.不幸的是,这会导致某些标准" IdentityServer3代码发生重大变化.即从他们的代码示例中提取,因此我想未来几天会有很多开发人员会看到此问题.

Microsoft's System.IdentityModels.Tokens.Jwt package was updated yesterday on NuGet from 4.0.2.206211351 to v5.0. This is unfortunately causing a breaking change with some "standard" IdentityServer3 code. i.e. taken from their code samples so I imagine quite a few developers might see this issue over the coming days.

使用v4.0.2.xxxxxx版本的软件包.我有

using v4.0.2.xxxxxx version of the package. I have

using System.IdentityModel.Tokens;

在命名空间中.

然后在Configuration方法中开始于:

then in the Configuration method begins as:

public void Configuration(IAppBuilder app) { AntiForgeryConfig.UniqueClaimTypeIdentifier = "sub"; JwtSecurityTokenHandler.InboundClaimTypeMap = new Dictionary<string, string>(); app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationType = "Cookies" }); app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions { ... };

更新后

更新配置行之后:

After Updating

After updating the confgiuration line:

JwtSecurityTokenHandler.InboundClaimTypeMap = new Dictionary<string, string>();

正在引起问题.

首先,显然,该类已移入System.IdentityModel.Tokens.Jwt命名空间,解决起来并不难.

The first thing being that the Class has, apparently, moved into the System.IdentityModel.Tokens.Jwt namespace, this isn't so bad to resolve.

但是,我现在在JwtSecurityTokenHandler.InboundClaimTypeMap上出现了Object reference required for a non-static field错误.

However, I'm now getting an Object reference required for a non-static field error on the JwtSecurityTokenHandler.InboundClaimTypeMap.

我在这里丢失了某些东西吗?需要另一个库吗?或者在调用Startup.Configuration()之前是否发生了需要挖掘的事情?

Am I missing something here, another library that's required or is there something happening before the Startup.Configuration() is called that needs digging into?

推荐答案

当您去看医生并说我这样做总是很疼"时-医生会回答然后停止这样做";)

When you go to the doctor and say "it always hurts when I do this" - the doctor will reply "then stopping doing this" ;)

v4-> v5从定义上来说是一个重大变化.您需要v5吗?

v4 -> v5 is by definition a breaking change. Do you need v5?

话虽如此-一个简单的智能探索将使他们将InboundClaimTypeMap重命名为DefaultInboundClaimTypeMap.

That being said - a simple intellisense exploration would have brought up that they renamed InboundClaimTypeMap to DefaultInboundClaimTypeMap.

准备在此过程中进行更多重大更改.

Be prepared for more breaking changes along the way.

更多推荐

System.IdentityModel.Tokens.Jwt的更新导致IdentityServer3 Client中的重大更改

本文发布于:2023-11-13 00:15:05,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1582877.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Tokens   IdentityModel   System   Client   Jwt

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!