title: Custom authorization in Web API - IClaimsPrincipal from ASP.Net Web API User (System.Security.Claims.ClaimsPrincipal)
body: <p>I have a Web API for which I need to do custom authorization. I'm using oAuth tokens and I was thinking I might do additional checks by implementing an authorizationManager</p>
  
  <pre><code>using Microsoft.IdentityModel.Claims;
  using System.Diagnostics;
  using System.Linq;
  
  public override bool CheckAccess(AuthorizationContext context){
      public override bool CheckAccess(AuthorizationContext context)
      {
          //authorization code here
      }
  }
  </code></pre>
  
  <p>The problem arises when I attempt to create an AuthorizationContext I don't have the right principal type. I noticed that from my Web API call I get a user which is a System.Security.Claims.ClaimsPrincipal which is not castable to IClaimsPrincipal which is needed by new AuthorizationContext.</p>
  
  <pre><code>var authorizationContext = new AuthorizationContext(principal, "resource", "action");//System.Security.Claims.ClaimsPrincipal is the wrong type of principal here, but is what user is on Web API call.
  </code></pre>
  
  <p>This of course results in the following error:</p>
  
  <p>cannot convert from 'System.Security.Claims.ClaimsPrincipal' to 'Microsoft.IdentityModel.Claims.IClaimsPrincipal'</p>
  
  <p>Is there something other than ClaimsAuthorizationManager I should be implementing? Is there a simple way to create the context object I need given the type of principal I have?</p>
  
  <p>I did notice that ClaimsAuthorizationManager is in Microsoft.IdentityModel.Claims while much of the other web api stuff is in Microsoft.AspNet.Identity or Microsoft.AspNet.Identity.Core which is perhaps a clue that it might not be the right thing to use.</p>