I'm using Spring Security 2.0.5.RELEASE and was wonder if it was possible to have two authentication providers set-up and then have a runtime flag determining which one to use.
e.g. Swapping between LDAP authentication and basic DB authentication.
So for example I'd like to have the following configured:
And have the DB authentication provider as a default, but be able to swap to the LDAP provider at runtime.
I'm using Spring Security 2.0.5.RELEASE and was wonder if it was possible to have two authentication providers set-up and then have a runtime flag determining which one to use.
Maybe you could have your custom authentication provider, backed by a LDAP authentication provider and a DB authentication provide, which uses a flag to dynamically switch between the two.
By the way, I would have thought that authentication providers do not change at runtime. i.e. I haven't seen applications where at runtime it would switch to a different authentication backend. They are usually configured during deployment time.
The Use Case is for a Web Console Administrator to choose between two authentication providers. So for example I'd like to be able to:
1.) Start with the DB authentication provider (supported by web pages that will allow them to change passwords etc)
2.) Swap to an Active Directory provider (which means that the change password etc functionality would be greyed out)
Your flag idea might just work, I probably can't get it to work purely dynamically (what would happen to users already logged in for example?), but it wouldn't be unreasonable to restart the web app after the config change.
Just add each provider to the list in the ProviderManager. You should have an equivalent in the security namespace. I just copied this from the Spring Security documentation.