通过附加到请求线程的安全主体访问声明,而不是AuthorizationContext

我正在使用Azure ACS实验室,他们使用FederatedServiceCredentials对Active Federation的用户进行身份验证。现在我想从WCF服务中访问用户的声明。 根据这篇文章,索赔是由请求线程访问的...任何人都可以解释或证明这意味着什么?     
已邀请:
请求线程是在服务器上执行服务API的线程。从该线程(也就是在您的服务API中),您可以访问Thread.CurrentPrincipal.Identity。这将是一个ClaimsIdentity,其中包含您的STS授予您的声明。例如:
 class MyService:IService
 {
   // code running on wcf server
   bool AdminOnlyApi()
   {    
     var identity = Thread.CurrentPrincipal.Identity as ClaimsIdentity;

     // fail all non admin callers.
     if (!identity.Claims.Exists(c=>c.ClaimType=="role" && c.Value=="Admin"))
     {
        throw new SecurityException("Access is denied.");
     }
     return True;
   }  
 }
    

要回复问题请先登录注册