c# - System.IdentityModel.Tokens.Jwt 的更新导致 IdentityServer3 客户端发生重大变化

标签 c# security identityserver3

希望是一个容易解决的问题。

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/

相关文章:

c# - 母版页和内容页中的 ScriptManager

c# - 使用 C# 将 UTF-8 转换为 ANSI

c# - string.Format 忽略 NumberFormatInfo?

security - PowerShell 安全日志

perl - 是否有比较可用于在 Perl 中开发 Web 应用程序的不同框架的功能的列表?

asp.net-core - 如何在 ASP.NET Core 客户端中使用 IdentityServer3?

angularjs - ASP.NET WebApi 安全 : Confusions with HMAC, OAuth、IdentityServer、Auth0

c# - 如何将 Storyboard动画应用于多个 xaml 元素

security - 使用外部 oauth2 提供商(facebook)时,我的应用程序是否应该发出自己的访问 token ?

c# - 使用 identityserver 将我的 webapi 与解析服务器连接起来