命名空间为.NET JWT令牌验证:系统与微软 [英] Namespaces for .NET JWT token validation: System vs. Microsoft
问题描述
我想使用JWT来验证节点应用到ASP.NET Web API。
I am trying to use JWT to authenticate a Node application to an ASP.NET Web API.
在ASP.NET中,我使用.NET 4.5.1和包的NuGet System.IdentityModel.Tokens.Jwt
5.0.0
In ASP.NET, I am using .NET 4.5.1 and nuget package System.IdentityModel.Tokens.Jwt
5.0.0
我不明白的是,为什么该命名空间微软
和系统
之间的混合。
What I don't understand is, why the namespaces are mixed between Microsoft
and System
.
例如:
var tokenReader = new JwtSecurityTokenHandler();
tokenReader.ValidateToken(token,
new TokenValidationParameters()
{
ValidateAudience = false
},
out validatedToken);
主要 JwtSecurityTokenHandler
是 System.IdentityModel.Tokens.Jwt
命名空间,但 TokenValidationParameters
类及其依赖性都在微软.IdentityModel.Tokens
命名空间,还可能与在 System.IdentityModel.Tokens
命名相似的类发生冲突。
The main JwtSecurityTokenHandler
is in the System.IdentityModel.Tokens.Jwt
namespace, but the TokenValidationParameters
class and its dependencies are in the Microsoft.IdentityModel.Tokens
namespace, and possibly collide with similar classes in the System.IdentityModel.Tokens
namespace.
在设计这还是这是一个版本不匹配其他地方的一个可能的迹象?
Is this by design or is this a possible sign of a version mismatch somewhere else?
推荐答案
如果您看一看依赖于
的的NuGet System.IdentityModel.Tokens.Jwt 4.0.2
VS
的NuGet System.IdentityModel.Tokens.Jwt 5.0
您会看到5.0对
依赖
.NETFramework 4.5.1
.NETFramework 4.5.1
Microsoft.IdentityModel.Tokens(> = 5.0.0)
Microsoft.IdentityModel.Tokens (>=5.0.0)
这4.0没有。事实上,没有以前的版本一样。
that 4.0 didn't have. In fact, no previous version did.
微软重新设计-ING其框架是重量越来越轻。在ASP.NET框架的大小,你将有很多的功能冗余。
Microsoft is re-architect-ing their frameworks to be more light weight. In a framework the size of ASP.NET, you will have many functional redundancies.
为使WIF更轻,同时保持向下兼容,该决定是由像 System.IdentityModel.Tokens.Jwt库删除冗余功能
不再依赖于 System.IdentityModel.Tokens
,但不是 Microsoft.IdentityModel.Tokens
。一个不幸的结果是,无论层露出的相同方法
To make WIF lighter, while remaining backwards compatible, the decision was made to remove the redundant functionality from libraries like System.IdentityModel.Tokens.Jwt
no longer depend on System.IdentityModel.Tokens
, but instead on Microsoft.IdentityModel.Tokens
. One of the unfortunate results is that both layers expose the same methods.
这篇关于命名空间为.NET JWT令牌验证:系统与微软的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!