title: ASP.Net Core SAML authentication
body: <p>I am trying to add SAML 2.0 authentication to an ASP.Net Core solution. I can't find any documentation on the subject, so I am unsure where to start. There is probably documentation out there, but I don't want to spend 3 days becoming an expert on this.</p>
  
  <p>From what I can see ASP.Net Core has changed something from the old OWIN assemblies/namespaces. There are third party libraries to simplify SAML 2.0 implementation such as <a href="https://github.com/KentorIT/authservices" rel="noreferrer">Kentor.AuthServices</a>.</p>
  
  <p>I am unsure how to combine this with ASP.Net 5 RC 1 / ASP.Net Core. For example making use of the AspNet* tables in SQL.</p>
  
  <p>ASP.Net 5 RC 1 comes with several libraries to implement authentication (client).</p>
  
  <p>For example:</p>
  
  <ul>
  <li><a href="https://github.com/aspnet/Security/tree/1.0.0-rc1/src/Microsoft.AspNet.Authentication.OAuth" rel="noreferrer">Microsoft.AspNet.Authentication.OAuth</a></li>
  <li><a href="https://github.com/aspnet/Security/tree/1.0.0-rc1/src/Microsoft.AspNet.Authentication.Facebook" rel="noreferrer">Microsoft.AspNet.Authentication.Facebook</a></li>
  <li><a href="https://github.com/aspnet/Security/tree/1.0.0-rc1/src/Microsoft.AspNet.Authentication.Google" rel="noreferrer">Microsoft.AspNet.Authentication.Google</a></li>
  <li><a href="https://github.com/aspnet/Security/tree/1.0.0-rc1/src/Microsoft.AspNet.Authentication.Twitter" rel="noreferrer">Microsoft.AspNet.Authentication.Twitter</a></li>
  </ul>
  
  <p>Implementing these is a matter of calling a simple extension method in <code>Startup.cs</code>:</p>
  
  <pre><code>app.UseIdentity()
  .UseFacebookAuthentication(new FacebookOptions
  {
      AppId = "ID",
      AppSecret = "KEY"
  })
  .UseGoogleAuthentication(new GoogleOptions
  {
      ClientId = "ID",
      ClientSecret = "SECRET"
  })
  .UseTwitterAuthentication(new TwitterOptions
  {
      ConsumerKey = "KEY",
      ConsumerSecret = "SECRET"
  });
  </code></pre>
  
  <p>Once that is done the ASP.Net sample project automatically shows social buttons for login/manage account:</p>
  
  <p><a href="https://i.stack.imgur.com/QHpeA.png" rel="noreferrer"><img src="https://i.stack.imgur.com/QHpeA.png" alt="Social buttons"></a></p>
  
  <p>In the backend code the authentication providers are retrieved using <code>var otherLogins = _signInManager.GetExternalAuthenticationSchemes().Where(auth =&gt; userLogins.All(ul =&gt; auth.AuthenticationScheme != ul.LoginProvider)).ToList();</code>. This means the authentication providers are registered somewhere that makes them available by calling <code>_signInManager.GetExternalAuthenticationSchemes()</code>.</p>
  
  <p>How can I implement SAML 2.0 authentication in ASP.Net 5 RC1 / ASP.Net Core?</p>