title: Authentication in a multi layer architecture
body: <p>I am designing an N-Layer system in .NET that will consist of </p>
  
  <ul>
  <li>SQL Server 2008</li>
  <li>EF 4</li>
  <li>Repository Layer</li>
  <li>Service Layer(Business Logic)</li>
  </ul>
  
  <p>On top of this I will have:</p>
  
  <ul>
  <li>ASP.NET MVC website </li>
  <li>external API to be consumed by other clients(built with WCF or ServceStack.NET)</li>
  </ul>
  
  <p>I would like to implement the typical username/password auth within the MVC app as well as OpenID/twitter/facebook login options</p>
  
  <p>The api will need similar forms of authentication.</p>
  
  <p>Where in the architecture is the best place to implement the authentication and are any samples available of how to implement something like this with a .NET Stack? </p>
  
  <p>Is a custom Membership provider an option for this? </p>
  
  <p>I realize that there are libraries available to implement the openID portion so that is not a concern at the moment but I would like to leave things open to add this in the future.</p>
  
  <p>Suggestions?</p>