title: Why is my ClaimsIdentity IsAuthenticated always false (for web api Authorize filter)?
body: <p>In a Web API project I am overriding the normal authentication process to check tokens instead. The code looks something like this:</p>
  
  <pre class="lang-cs prettyprint-override"><code>if ( true ) // validate the token or whatever here
  {
      var claims = new List&lt;Claim&gt;();
      claims.Add( new Claim( ClaimTypes.Name, "MyUser" ) );
      claims.Add( new Claim( ClaimTypes.NameIdentifier, "MyUserID" ) );
      claims.Add( new Claim( ClaimTypes.Role, "MyRole" ) );
  
      var claimsIdentity = new ClaimsIdentity( claims );
  
      var principal = new ClaimsPrincipal( new[] { claimsIdentity } );
      Thread.CurrentPrincipal = principal;
      HttpContext.Current.User = principal;
  }
  </code></pre>
  
  <p>And then later when I apply the <code>[Authorize]</code> attribute to a controller, it fails to authorize.</p>
  
  <p>Debug code confirms the same behavior:</p>
  
  <pre class="lang-cs prettyprint-override"><code>// ALWAYS FALSE!
  if ( HttpContext.Current.User.Identity.IsAuthenticated ) {
      // do something
  }
  </code></pre>
  
  <p>Why does it think the user is not authenticated even though I've constructed a valid ClaimsIdentity and assigned it to the thread?</p>