Sustainsys / Saml2

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

Configure as SP with multiple IDPs #1217

Open gitdrk opened 4 years ago

gitdrk commented 4 years ago

I have configured an instance of IdentityServer4 to act as a SP using this library. I am able to successfully use multiple IDPs by adding multiple Schemes for SP initiated SSO.

Here is the code I use for this which works well but it creates multiple instances of the SP.

        //add IDPs at startup - saml providers comes from DB
        foreach (var samlProvider in samlProviders)
        {               
            authenticationBuilder.AddSaml2(samlProvider.Scheme, samlProvider.Name, options =>
            {                   
                var entityId = new EntityId(my.EntityId);
                options.SignInScheme = IdentityServerConstants.ExternalCookieAuthenticationScheme;
                options.SPOptions.EntityId = entityId;
                options.SPOptions.ModulePath = samlProvider.ModulePath;

                if (samlProvider.MinimumSigningAlgorithm != null)
                    options.SPOptions.MinIncomingSigningAlgorithm = samlProvider.MinimumSigningAlgorithm;

                var idp = new IdentityProvider(entityId, options.SPOptions)
                {
                    Binding = Saml2BindingType.HttpRedirect,
                    LoadMetadata = true
                };

                if (samlProvider.MetaDataLocation != null)
                    idp.MetadataLocation = samlProvider.MetaDataLocation;

                options.IdentityProviders.Add(idp);
            });
        }

Thanks in advance for any assistance!

AlexOliinyk1 commented 3 years ago

Any updates here?

AndersAbel commented 2 years ago

Looks like something to investigate for the v3 work - I am thinking of a redesign with the IdentityProviders vs. schemes architecture.

ghstahl commented 1 year ago

Does anyone have a fork that we can use in the meantime.

IAMHK90 commented 11 months ago

@gitdrk , Mutiple instances of Identityserver meaning different urls?
did you find a way to create single instance of Identityserver with Mutiple saml IDPs?