相关疑难解决方法(0)

更新System.IdentityModel.Tokens.Jwt导致IdentityServer3客户端发生重大更改

希望很容易解决.

微软的System.IdentityModels.Tokens.Jwt软件包昨天在NuGet上更新4.0.2.206211351v5.0.不幸的是,这导致了一些"标准" IdentityServer3代码的突破性变化.即从他们的代码示例中提取,所以我想很多开发人员可能会在未来几天看到这个问题.

原始代码

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

using System.IdentityModel.Tokens;
Run Code Online (Sandbox Code Playgroud)

在命名空间中.

然后在Configuration方法中开始如下:

public void Configuration(IAppBuilder app)
    {
        AntiForgeryConfig.UniqueClaimTypeIdentifier = "sub";

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

        app.UseCookieAuthentication(new CookieAuthenticationOptions
        {
            AuthenticationType = "Cookies"
        });

        app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions
        { ... };
Run Code Online (Sandbox Code Playgroud)

更新后

更新说明行后:

JwtSecurityTokenHandler.InboundClaimTypeMap = new Dictionary<string, string>();
Run Code Online (Sandbox Code Playgroud)

造成问题.

第一件事就是Class显然已经进入了System.IdentityModel.Tokens.Jwt命名空间,这个解决方案并不是那么糟糕.

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

我是否在这里遗漏了一些东西,另一个需要的库或者在Startup.Configuration()被调用之前发生了什么需要深入研究?

c# security identityserver3

26
推荐指数
1
解决办法
5784
查看次数

标签 统计

c# ×1

identityserver3 ×1

security ×1