title: Identity server 4 with SAML 2.0 as external identity provider for SSO
body: <p>I am using identity server 4 for authentication to my ASP.Net Core solution. And it is working well with Facebook, Google and other external identity provider.
  And now I am trying to add SAML 2.0 authentication to the identity server using Sustainsys.Saml2 from <a href="https://github.com/Sustainsys/Saml2" rel="noreferrer">https://github.com/Sustainsys/Saml2</a> and making it work as an external identity provider.  (Customers to our site want to login using their SAML identity provider using our Identity Server in the same way they can login via Facebook, Google, etc)</p>
  
  <p>And what I have now is the </p>
  
  <ol>
  <li><p>sign in URL - <a href="https://sso.domain.com/saml/idp/profile/redirectorpost/sso" rel="noreferrer">https://sso.domain.com/saml/idp/profile/redirectorpost/sso</a></p></li>
  <li><p>sign out URL - <a href="https://sso.domain.com/saml/idp/profile/post/sls" rel="noreferrer">https://sso.domain.com/saml/idp/profile/post/sls</a></p></li>
  <li>CRT certificate 
  for the SAML based identity provider of our customer. </li>
  </ol>
  
  <p>However, I cannot find the document that describes how to setup the configuration of SAML 2.0 in identity server 4 startup.cs file.
  I think the configuration should look like the following based on the sample available at: 
  <a href="https://github.com/Sustainsys/Saml2/blob/master/Samples/SampleAspNetCore2ApplicationNETFramework/Startup.cs" rel="noreferrer">https://github.com/Sustainsys/Saml2/blob/master/Samples/SampleAspNetCore2ApplicationNETFramework/Startup.cs</a></p>
  
  <pre><code>services.AddAuthentication()
      .AddSaml2(options =&gt; 
          {
              options.SPOptions.EntityId = new EntityId("..."); 
              options.IdentityProviders.Add(
                  new IdentityProvider(
                          new EntityId("..."), options.SPOptions)
                          {
                              LoadMetadata = true,
                          });
              options.SPOptions.ServiceCertificates.Add(new X509Certificate2("..."));
         }
      );
  </code></pre>
  
  <p>In the sample there are two url's</p>
  
  <ol>
  <li><p><a href="https://localhost:44342/Saml2" rel="noreferrer">https://localhost:44342/Saml2</a> </p></li>
  <li><p><a href="http://localhost:52071/Metadata" rel="noreferrer">http://localhost:52071/Metadata</a></p></li>
  </ol>
  
  <p>What do these <strong>represent</strong>? </p>
  
  <p><strong>Can somebody tell me how to setup all the options for SAML2 in identity server 4?</strong></p>