Security icon indicating copy to clipboard operation
Security copied to clipboard

Add/Remove/Configure Authentication Middleware at Runtime

Open windischb opened this issue 9 years ago • 9 comments

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

windischb avatar Feb 21 '17 11:02 windischb

Not today, @hoak is building this feature right now: https://github.com/aspnet/Security/pull/1113, your feedback would be appreciated.

Tratcher avatar Feb 21 '17 13:02 Tratcher

Thanks!

windischb avatar Feb 21 '17 18:02 windischb

I'll add a unit test today to make sure we support adding and removing schemes dynamically works in the new stack

HaoK avatar Feb 21 '17 19:02 HaoK

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.

daboul avatar Feb 22 '17 09:02 daboul

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.

HaoK avatar Feb 22 '17 22:02 HaoK

We need to carefully consider threading scenarios such as:

  1. Reader/writer scenarios to ensure no unusual exceptions get thrown during normal operations
  2. Consistency within a request to ensure that during a request the state doesn't change (could cause very weird side-effects)

Eilon avatar Feb 23 '17 23:02 Eilon

Tracked via https://github.com/aspnet/Security/issues/1179

HaoK avatar Apr 13 '17 23:04 HaoK

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!

JohnGalt1717 avatar Nov 20 '18 12:11 JohnGalt1717

Here's a sample: https://github.com/aspnet/AspNetCore/tree/5a6b6c90b6e32ecab4975c546228cc63199f168b/src/AuthSamples/samples/DynamicSchemes

Tratcher avatar Nov 20 '18 13:11 Tratcher