Home > Enterprise >  Asp.Net Core - modify authentication schemes while server is running
Asp.Net Core - modify authentication schemes while server is running

Time:10-20

Is there a way to modify/add/remove authentication schemes while server is running?

(need to add scheme without restarting my server)

CodePudding user response:

The key for adding new scheme resides withing the IOptionsFactory<TOptions> object.

While you may configure multiple IAuthenticationHandler's of same type the authenticationScheme fields specifies each's configuration (in sourcecode it is refered as TOptions).

As all runtime options are configured and "sealed" at startup (see: enter image description here

enter image description here

After adding oidc2 scheme programatically - oidc2 can access identity provider enter image description here

CodePudding user response:

If you want change the code which is running in your server, it's impossible to modify authentication schemes.

Unless you use Azure webapp, you can create a slot to hot start your application.

Suggestion:

You need change your code, and rebuild your project, and you must retsart your webapp. You can think about how to add authentication schemes dynamically.

AuthSamples.DynamicSchemes

This repo should be useful to you. For more details, you can refer below post.

Adding new authentication schemes dynamically

  • Related