title: C# Authorize Attribute Logic
body: <p>I'm trying to implement the <code>Authorize</code> attribute in my WebApi Controllers. I've found resources on how to implement <code>Authorize</code>, and even that I need to set the Thread and HttpContext Principals when implementing Authorization. But I can't find an example of how/where I write the Authorization logic.</p>
  
  <pre><code>public class MyController : ApiController
  {
      [Route("")]
      [Authorize]
      public async Task&lt;IHttpActionResult&gt; Get() {}
  }
  public class MyAuthorizationProvider
  {
      public void AuthorizeIGuess()
      {
          string authHeader = HttpContext.Request.Headers.GetValues("Authorization").FirstOrDefault();
  
          // do stuff with auth header
          // create principal
  
          HttpContext.Current.User = ...;
          Thread.CurrentPrincipal = ...;
      }
  }
  </code></pre>
  
  <p>How do I setup <code>MyAuthorizationProvider</code> so that it is used for <code>Authorize</code>, and is this how I set my auth context?</p>