Add/Remove/Configure Authentication Middleware at Runtime
Hi!
Is it possible to add and remove AuthenticationMiddleware at Runtime? I wan't to configure/add/remove OpenIdConnectAuthenticationProviders inside a WebGui.
I was thinking about storing the ProviderOptions in a Database, with the AuthenticationScheme as GUID.
In my special case i wan't to use IdentityServer4 for multiple Customers. If an new Customer arrives, i will add a new "Provider" to the Database an register it as Middleware in the pipeline. On the other side, i have to unregister the Provider and delete from Database.
Or maybe is it possible to query the Database on every Challenge if the AuthenticationScheme exists??
Any Ideas? I have the need to add/remove/configure OpenIdConnectAuthentication without recompile or restart the Asp.net Core WebApplication...
Br
Not today, @hoak is building this feature right now: https://github.com/aspnet/Security/pull/1113, your feedback would be appreciated.
Thanks!
I'll add a unit test today to make sure we support adding and removing schemes dynamically works in the new stack
Hi. I was wondering the exact same thing and just asked about it on SO.
http://stackoverflow.com/questions/42365743/installing-a-new-middleware-at-runtime-in-asp-net-core
I'll definitively give it a try when it's out.
Thanks.
See https://github.com/aspnet/Security/pull/1113/commits/d92d92384f7f6cf2e5e17c975efaa0bd6ab299c0 for what it currently looks like, basically its just associating a schemeName with a handlerType in a new service.
We need to carefully consider threading scenarios such as:
- Reader/writer scenarios to ensure no unusual exceptions get thrown during normal operations
- Consistency within a request to ensure that during a request the state doesn't change (could cause very weird side-effects)
Tracked via https://github.com/aspnet/Security/issues/1179
Where's this at? Is this now possible? Is there documentation on how to do it? I need to be able to add/remove these via a UI without having to restart our api layer every time.
Thanks!
Here's a sample: https://github.com/aspnet/AspNetCore/tree/5a6b6c90b6e32ecab4975c546228cc63199f168b/src/AuthSamples/samples/DynamicSchemes