title: Add roles to ADFS IPrincipal
body: <p>I have been looking for answer to this question for a few days now, but I have not found any success.  I would post the links, but it would probably take up the entire page.  </p>
  
  <p>So here is what I have...</p>
  
  <p>I have an MVC application, which uses the WC-Federation protocol.  I have been able to configure the application, so that it authenticates the users, and returns the claims from ADFS.  This works perfect.  I can also extract all the claims with no issues.  But I am doing this within one of the actions in the controller.  </p>
  
  <p>And here is what I want to do...</p>
  
  <p>I want to use ADFS to authenticate the user, but I want to use my own internal roles to authorize the user to have access to specific controllers (e.g. <code>[Authorize(Roles = "CoolRole")]</code>).  I want to be able to do this, because I already have a Web API that uses OAuth 2.0, with a backend SQL Server database to manage users and roles (internal and external user.)  I now want a secure portal that will allow internal users to access the data with a single-sign-on experience.  Looking at the <code>Controller</code> model, I noticed there are some properties associated with the authentication process (<code>OnAuthentication</code>, <code>OnAuthenticationChallenge</code>) and one for the authorization process (<code>OnAuthorization</code>.)</p>
  
  <p>I don't necessarily need the code, but I feel like I've hit a brick all, and I need to be pointed in the right direction.</p>
  
  <p>UPDATE</p>
  
  <p>I tried this:</p>
  
  <pre><code>protected override void OnAuthorization(
         System.Web.Mvc.AuthorizationContext filterContext)
  {
      //Private class to create a new IPrincipal based on my AppUserMgr
      var user =  _setCurrentUser(
                    (ClaimsIdentity)filterContext.HttpContext.User.Identity);
      filterContext.HttpContext.User = user;
  
      base.OnAuthorization(filterContext);
  }
  </code></pre>
  
  <p>This returned a 401 (Unauthorized) response. </p>
  
  <p>and...</p>
  
  <pre><code>protected override void OnAuthentication(
      System.Web.Mvc.Filters.AuthenticationContext filterContext)
  {
      //Private class to create a new IPrincipal based on my AppUserMgr
      var user =  _setCurrentUser(
                    (ClaimsIdentity)filterContext.HttpContext.User.Identity);
      filterContext.Principal = user;
  
      base.OnAuthorization(filterContext);
  }
  </code></pre>
  
  <p>This just calls the STS numerous times, before it fails.  I even tried swapping after the assignment to after the base is called in both.  No luck.</p>
  
  <p>Prior to the previous ones, I also tried to add an AuthorizeFilter to the control, but that didn't help:</p>
  
  <p><a href="http://pratapreddypilaka.blogspot.in/2012/03/custom-filters-in-mvc-authorization.html" rel="nofollow noreferrer">http://pratapreddypilaka.blogspot.in/2012/03/custom-filters-in-mvc-authorization.html</a></p>