Tag: 声明为基础的身份

Thread.CurrentPrincipal已经过身份validation,但ClaimsPrincipal.Current不是

我在我的WebApi项目中使用基于声明的授权,并且有一种方法可以检查当前身份是否经过身份validation。 当我使用ClaimsPrincipal.Current ,当前的身份未经过身份validation,但是当我使用Thread.CurrentPrincipal它就是。 ClaimsPrincipal.Current.Identity.IsAuthenticated; //False Thread.CurrentPrincipal.Identity.IsAuthenticated; //True 这看起来很奇怪,特别是因为MSDN说 ClaimsPrincipal.Current只返回Thread.CurrentPrincipal: 备注 默认情况下,返回Thread.CurrentPrincipal。 您可以通过设置ClaimsPrincipalSelector属性来指定要调用的委托来确定当前主体,从而更改此行为。 有人可以解释一下为什么ClaimsPrincipal未经过身份validation,而理论上两者都包含相同的身份吗?

claim-types中的URL是什么

由于我想在我的应用程序中添加自定义声明,因此我检查了ClaimTypes的源代码(使用JetBrains反编译器反编译)。 这是它的一部分: namespace System.Security.Claims { /// Defines constants for the well-known claim types that can be assigned to a subject. This class cannot be inherited. [ComVisible(false)] public static class ClaimTypes { internal const string ClaimTypeNamespace = “http://schemas.microsoft.com/ws/2008/06/identity/claims”; /// The URI for a claim that specifies the instant at which an entity was authenticated; http://schemas.microsoft.com/ws/2008/06/identity/claims/authenticationinstant. public […]