Sustainsys / Saml2

Saml2 Authentication services for ASP.NET
Other
960 stars 603 forks source link

Adding 2nd provider #626

Closed piermorosini closed 6 years ago

piermorosini commented 7 years ago

Hi adding 2nd provider in this way

//***1st provider works fine var spOptionsAuth0 = new SPOptions { EntityId = new EntityId("urn:xxxxxxxxxxxxxxxxxxxxxxxxx1"), ReturnUrl = new Uri("xxxxxxxxxxxxxxxxxxx1/Account/ExternalLoginCallback"), }; spOptionsAuth0.ServiceCertificates.Add(new X509Certificate2( AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "/Certificates/Kentor.AuthServices.Tests.pfx", "", X509KeyStorageFlags.MachineKeySet)); var authServicesOptionsAuth0 = new KentorAuthServicesAuthenticationOptions(false) { SPOptions = spOptionsAuth0 }; var idpAuth0 = new IdentityProvider(new EntityId("urn:xxxxxxxxxxxxxxxxxxxxxxx1"), spOptionsAuth0) { AllowUnsolicitedAuthnResponse = true, Binding = Saml2BindingType.HttpRedirect, SingleSignOnServiceUrl = new Uri("xxxxxxxxxxxx1/samlp/FAycoSlqtr5Uc66Euv3o1cDITt22dQ2B") }; idpAuth0.SigningKeys.AddConfiguredKey( new X509Certificate2( HostingEnvironment.MapPath( "~/Certificates/xxxxxxxxxxxx.1cer")));

        authServicesOptionsAuth0.IdentityProviders.Add(idpAuth0);
        app.UseKentorAuthServicesAuthentication(authServicesOptionsAuth0);

//***2nd provider var spOptionsAuth0 = new SPOptions { EntityId = new EntityId("urn:xxxxxxxxxxxxxxxxxxxxxxxxx2"), ReturnUrl = new Uri("xxxxxxxxxxxxxxxxxxx2/Account/ExternalLoginCallback"), }; spOptionsAuth0.ServiceCertificates.Add(new X509Certificate2( AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "/Certificates/Kentor.AuthServices.Tests.pfx", "", X509KeyStorageFlags.MachineKeySet)); var authServicesOptionsAuth0 = new KentorAuthServicesAuthenticationOptions(false) { SPOptions = spOptionsAuth0 }; var idpAuth0 = new IdentityProvider(new EntityId("urn:xxxxxxxxxxxxxxx2"), spOptionsAuth0) { AllowUnsolicitedAuthnResponse = true, Binding = Saml2BindingType.HttpRedirect, SingleSignOnServiceUrl = new Uri("xxxxxxxxxxxx2/samlp/FAycoSlqtr5Uc66Euv3o1cDITt22dQ2B") }; idpAuth0.SigningKeys.AddConfiguredKey( new X509Certificate2( HostingEnvironment.MapPath( "~/Certificates/xxxxxxxxxxxx2.cer")));

        authServicesOptionsAuth0.IdentityProviders.Add(idpAuth0);
        app.UseKentorAuthServicesAuthentication(authServicesOptionsAuth0);

in @foreach (AuthenticationDescription p in loginProviders) {

    }

Both certificates have the same link

Thanks for help Pierluigi

explunit commented 7 years ago

I don't comprehend your full example, but the key when using OWIN middleware and multiple instances is that each one needs to have a separate SPOptions.ModulePath value. There is an example here: https://github.com/KentorIT/authservices/blob/master/doc/IdentityServer3Okta.md

piermorosini commented 7 years ago

Hi thanks for reply.

. a single GetCoreOktaOptions method (sets up the options common to each instance, and sets the module path based on input param)

Sorry, I looked to that page but I wasn't able to understand what is Module path. It's a folder path? If yes what is folder content?

Many thanks for help Pierluigi

explunit commented 7 years ago

It's just a virtual path that lets the middleware separate the requests coming back from the IDPs. You do not need any content at that path.

The line I was referring to in the example code was this one:

ModulePath = string.Format("/{0}", idpName) // this is important -- it is what drives the separate instances

piermorosini commented 7 years ago

Ok I try Thanks for help Have a good day

AndersAbel commented 6 years ago

Old issue without recent activity, closing.