title: MVC 5 IoC and Authentication
body: <p>I am just about to start on a project, where I will be using MVC5. But as I want to use IoC and later reuse my user tables, and add custom stuff to it, I am finding it very hard to see how I can use the new Identity framework that came with MVC5.</p>
  
  <p>I am more and more looking towards basic forms auth. What are your solutions?</p>
  
  <p>My needs:</p>
  
  <ul>
  <li>User repository/service must be injected</li>
  <li>User repository must reside in the DAL</li>
  <li>User repository must be able to support other technologies than EF</li>
  <li>Authentication with OpenID and OAuth must be somewhat easy to implement</li>
  <li>MUST BE SECURE</li>
  <li>Should be reusable in other projects, eg. WPF</li>
  </ul>
  
  <p>I have been looking for a long time for an answer, but everything I see is hardcoded in the controller.</p>
  
  <p>How are you solving this? Are you writing most from scratch, or can you bind into something that will scale to other .NET platforms as WCF and WPF?</p>
  
  <p>The below code is taken directly from the AccountController in the default ASP.NET MVC 5 Template.
  The first thing it does is a <code>Bastard Injection</code>.</p>
  
  <pre><code>[Authorize]
  public class AccountController : Controller
  {
      public AccountController()
          : this(
              new UserManager&lt;ApplicationUser&gt;(
                  new UserStore&lt;ApplicationUser&gt;(
                      new ApplicationDbContext())))
      {
      }
  
      public AccountController(UserManager&lt;ApplicationUser&gt; userManager)
      {
          UserManager = userManager;
      }
  }
  </code></pre>
  
  <p><strong>The accepted answer will go to the person, that shows me what they have done, that incorporates the above requirements</strong></p>