1
votes

Is it possible to set IdentityProvider options (EntityId, MetadataLocation) for Saml2 outside the Startup.cs class in an ASP.NET Core application using the Sustainsys.Saml2 library?

In my scenario, different customers will require different settings, so I will need to change the settings at runtime rather than application start.

1
Do you want to change Saml2Options.SPOptions.EntityId or IdentityProviders to add new IdentityProvider? For Saml2Options, you could access it by IOptions<Saml2Options> options, but for Saml2Options.SPOptions.EntityId, it will not be able to edit if you have set saml2PSecurityTokenHandler. - Edward
I'm looking to change the options rather than add a new provider. How can I access IOptions<Saml2Options>. Can in be injected into a controller for example? - Robert Dougan

1 Answers

2
votes

Yes. You can both change the settings of the IdentityProvider object as well as add new or remove old Idps from the IdentityProvider dictionary. Don't change the EntityId though as that is used as the key in the dictionary. Remove/add new instead.

There are also notifications you can use to entirely bypass the built in list of Idps and instead use your own store or create Idp objects on-the-fly.

If you use Metadata loading you should really cache them, as creating one with Metadata loading requires an outbound roundtrip to download metadata before it can be used.