Authenticate Using Two Custom BasicAuthProviders

Hello, I currently have a project that uses a custom auth provider that is a subclass of BasicAuthProvider. It authenticates services using the [Authenticate] attribute and works exactly as needed.

I now want to create a second custom auth provider that is also a subclass of BasicAuthProvider. I would like to have some services authenticated with this new one, but some to remain authenticated by the old one. Is there a way for me to accomplish this? Either with the [Authenticate] attribute or another way?

I see that you can specify the provider you want to use on the service this way: [Authenticate(“provider”)], but as far as I can tell and based on my attempts, this will not help me since they are both “basic”. Is that correct?

Appreciate any help!

You can change the provider name in your sub class by changing the base.Provider property but there should only 1 HTTP Basic Auth provider otherwise you couldn’t use the normal [Authenticate] attribute without specifying a provider as they would be in conflict where both would try to authenticate any HTTP Basic Auth requests.

So I would only have a single Basic Auth Provider and distinguish behavior using something like a custom HTTP Header.