Skip to content

Instantly share code, notes, and snippets.

@dsolovay
Last active December 8, 2021 06:01
Show Gist options
  • Save dsolovay/589c1f01c56fd3bd11b94d6185aa5aa1 to your computer and use it in GitHub Desktop.
Save dsolovay/589c1f01c56fd3bd11b94d6185aa5aa1 to your computer and use it in GitHub Desktop.
Sitecore Identity to Sustainsys Plugin
using IdentityServer4;
using Microsoft.AspNetCore.Authentication;
using Microsoft.Extensions.DependencyInjection;
using Sustainsys.Saml2;
using Sustainsys.Saml2.Configuration;
using Sustainsys.Saml2.Metadata;
using Sustainsys.Saml2.WebSso;
namespace SitecoreIdentitySamlDemo
{
public class ConfigureSitecore
{
public void ConfigureServices(IServiceCollection services)
{
var builder = new AuthenticationBuilder(services);
builder.AddSaml2("Saml2", "SSO Button Text", options =>
{
options.SignInScheme = "idsrv.external";
options.SignOutScheme = IdentityServerConstants.DefaultCookieAuthenticationScheme;
options.SPOptions.EntityId = new EntityId("https://testidserver2/Saml2");
IdentityProvider provider = GetIdentityProvider(options.SPOptions);
options.IdentityProviders.Add(provider);
});
}
private IdentityProvider GetIdentityProvider(SPOptions options)
{
var idp = new IdentityProvider(new EntityId("https://stubidp.sustainsys.com/Metadata"), options);
idp.Binding = Saml2BindingType.HttpPost;
idp.LoadMetadata = true;
return idp;
}
}
}
@dsolovay
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment