Sustainsys / Saml2

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

Selected Idp in Owin context is ignored #1065

Closed jonasPri closed 2 years ago

jonasPri commented 5 years ago

We recently updated to 2.2 and are having an issue where the selected Idp is ignored. Instead it uses the first Idp added to the application. It's an OWIN based project and we are using the Idp selection outlined in the docs. var context = HttpContext.Current.GetOwinContext(); context.Environment.Add("saml2.idp", new EntityId(idp));

Is this no longer supported in 2.2?

AndersAbel commented 5 years ago

The reason for this is probably a confusion about what "EntityId" class to use. When working in an Owin application, you likely get a reference to System.IdentityModel so the EntityId will be an instance of System.IdentityModel.Metadata.EntityId. However, in 2.x System.IdentityModel is not used. The right EntityId class to use is Sustainsys.Saml2.Metadata.EntityId.

This is completely confusing. So I'll add a conversion to the owin middleware that checks for System.IdentityModel.Metadata.EntityId and converts it to Sustainsys.Saml2.Metadata.EntityId. But for new ensure that it is an instance of Sustainsys.Saml2.Metadata.EntityId that you put in the owin environment.

AndersAbel commented 2 years ago

Not critical enough for getting patched on Owin.