Sustainsys / Saml2

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

How to add thumbprints programmatically using HttpModule. #1377

Closed trufun202 closed 1 year ago

trufun202 commented 1 year ago

I've recently updated from Kentor to Sustainsys, and I am now looking to move my SAML2 tenant thumbprints from the web.config to a database. This way I can add/delete/modify thumbprints without re-deploying the project. To do so, I need the ability to specify the thumbprint in the code.

Can you provide a code example of how the thumbprint would be set programmatically? I’m using the HttpModule. I’ve tried accessing:

Sustainsys.Saml2.HttpModule.Saml2AuthenticationModule.Options

And

Sustainsys.Saml2.Configuration.Options.FromConfiguration

But both of them throw the following exception:

Value cannot be null. Parameter name: configSection Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentNullException: Value cannot be null. Parameter name: configSection

Any suggestions or sample code would be greatly appreciated.

Thank you!

AndersAbel commented 1 year ago

You still need the config section in the web.config - that's the base for the HttpModule configuration. Then you can add/alter on top of that programmatically.