Multiple credentials auth providers in chain

Can I chain multiple auth providers?

E.g. I’ve made a LdapAuthProvider, which subclasses CredentialsAuthProvider, and now I’d like to create another ConfigFileCredentialsProvider, also subclassing the CredentialsAuthProvider (for system users, which don’t exist in LDAP).

I tried to chain like this:

appHost.Plugins.Add(new AuthFeature(() =>
                new CustomUserSession(),
                new IAuthProvider[] {
                    new ConfigCredentialsAuthProvider(AppSettings),
                    new LdapCredentialsAuthProvider(AppSettings),

But it doesn’t go from one to the next.
So I tried to set the Name, but need some help with that (tried multiple variants, new, etc).

It would be perfectly fine if
/auth/configcreds -> ConfigCredProvider
/auth/credentials -> LdapCredentialsProvider

or some sort like that.

You’ll need to change the Provider name and AuthRealm, e.g:

    Provider = "configcreds";
    AuthRealm = "/auth/configcreds";

That worked beautifully - thanks! You even answered on a Saturday!

For reference (for others), when I call from my “script” which should authenticate with the credentials from a config file, I specify the provider like this:

client.Send(new Authenticate
    provider = "configcreds",
    // then: UserName, Password, etc...
1 Like