升级到 5.0.0 后,TokenValidationParameters 不再工作

TokenValidationParameters no longer working after upgrade to 5.0.0(升级到 5.0.0 后,TokenValidationParameters 不再工作)
本文介绍了升级到 5.0.0 后,TokenValidationParameters 不再工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我有以下代码在我使用时可以正常工作System.IdentityModel.Tokens.Jwt,版本=4.0.20622.1351

I have the following code which was working when I was using System.IdentityModel.Tokens.Jwt, Version=4.0.20622.1351

private static void ConfigureAzureAD(IAppBuilder appBuilder)
{
    appBuilder.UseWindowsAzureActiveDirectoryBearerAuthentication(
        new WindowsAzureActiveDirectoryBearerAuthenticationOptions
        {
            Tenant = ConfigurationManager.AppSettings["ida:Tenant"],
            TokenValidationParameters = new System.IdentityModel.Tokens.TokenValidationParameters
            {
                ValidAudience = ConfigurationManager.AppSettings["ida:Audience"]
            }
        });
}

但是,一旦我将此包升级到最新的 版本 5它不再编译抱怨对类型TokenValidationParameters"的引用声称它在 System.IdentityModel.Token.Jwt 中定义,但找不到.

However as soon as I upgraded this package to the latest one which is version 5 it no longer compiles complaining Reference to type 'TokenValidationParameters' claims it is defined in System.IdentityModel.Token.Jwt but it could not be found.

此外,如果您尝试以下编译器,则会警告您 Audience 已过时:

Also if you try the following compiler will warn you that Audience is obsolete:

 private static void ConfigureAzureAD(IAppBuilder appBuilder)
    {
        appBuilder.UseWindowsAzureActiveDirectoryBearerAuthentication(
            new WindowsAzureActiveDirectoryBearerAuthenticationOptions
            {
                Tenant = ConfigurationManager.AppSettings["ida:Tenant"],
                Audience = ConfigurationManager.AppSettings["ida:Audience"]
            });
    }

我再次降级了这个 DLL 并使用了 4.0.20622.1351 版本,它开始编译.

I downgraded this DLL again and used the version 4.0.20622.1351, it started compiling.

配置 Azure Active Directory 的语法是否发生了变化?

Has there been a syntax change for Configuring the Azure Active Directory?

在 Github 上,我找不到使用最新包 5.0.0 的单个项目,并且所有项目都使用以前的包 4.0.20622.1351.任何人都可以使用最新的 System.IdentityModel.Tokens.Jwt 5.0.0 对此有所了解,或者使用最新的软件包将我引导到 Github 上的某个项目吗?

On Github I could not find a single project using the latest package 5.0.0 and all of them are using the previous package 4.0.20622.1351. Can anyone shed some light on this using the latest System.IdentityModel.Tokens.Jwt 5.0.0 or direct me to some project on Github using the latest package?

推荐答案

TokenValidationParameters 在汇编中:Microsoft.IdentityModel.Tokens

TokenValidationParameters is in assembly: Microsoft.IdentityModel.Tokens

看起来您正在使用 Katana(asp.net OWIN 产品的第一个版本).Katana 不支持 5.0.0.您需要坚持使用 4.x.

It looks like you are using Katana (the first version of asp.net OWIN offering). Katana does not support 5.0.0. You need to stick with 4.x.

最新版本的 asp.net 依赖于 S.IM.xx 和 M.IM.xxx 5.0.https://github.com/aspnet

The latest version of asp.net takes a dependency on S.IM.xx and M.IM.xxx 5.0. https://github.com/aspnet

这篇关于升级到 5.0.0 后,TokenValidationParameters 不再工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

How to MOQ an Indexed property(如何最小起订量索引属性)
Mocking generic methods in Moq without specifying T(在 Moq 中模拟泛型方法而不指定 T)
How Moles Isolation framework is implemented?(Moles Isolation 框架是如何实现的?)
Difference between Dependency Injection and Mocking Framework (Ninject vs RhinoMocks or Moq)(依赖注入和模拟框架之间的区别(Ninject vs RhinoMocks 或 Moq))
How to mock Controller.User using moq(如何使用 moq 模拟 Controller.User)
How do I mock a class without an interface?(如何模拟没有接口的类?)