Sustainsys / Saml2

Saml2 Authentication services for ASP.NET
Other
945 stars 605 forks source link

How to implement dynamic options provider for Saml2 IDP (e.g. Shibboleth IDP) in IdentityServer4 implementation? #1364

Closed prrami closed 1 year ago

prrami commented 1 year ago

In our IdentiyServer4 implementation, we have implemented option provider for OpenIDConnect which gets resolved at runtime and provides dynamic options as per IDP like aad/okta/onelogin. Now we want to support Saml2 IDP(Shibboleth in our case) also and want to implement option provider for Saml2 so we can assign dynamic options at runtime. We are using Systainsys.Saml2.AspNetCore2 NuGet to support Saml2 IDP.

right now we have created Saml2OptionsProvider class and have it registered for Saml2Options in Program.cs as below same as we have done for OpenIDConnect but didn't get success to resolve this.

builder.Services.AddScoped<IOptionsMonitor<Saml2Options>, Saml2OptionsProvider>(); 

services.AddAuthentication()
.AddOpenIdConnect("aad", "Azure AD", options =>
            {
                options.SignInScheme = IdentityServerConstants.ExternalCookieAuthenticationScheme;
                options.SignOutScheme = IdentityServerConstants.SignoutScheme;
            })
.AddSaml2("Saml2", "Saml2", options =>
            {
                options.SignInScheme = IdentityServerConstants.ExternalCookieAuthenticationScheme;
                options.SignOutScheme = IdentityServerConstants.DefaultCookieAuthenticationScheme;

            })

As shown above two options are set here in program.cs. Other we want to set runtime using option provider. Please share details if you have any idea on how to implement same.

prrami commented 1 year ago

Closing as its duplicated