Tag Archives: Authentication provider

Spring Security – Multiple authentication providers

An AuthenticationManager is responsible for passing requests through a chain of AuthenticationProviders. It is very much similar to the filter chain in a typical web application.

These authentication providers are tried in the order shown (which is implied by the use of a List instead of a Set), with each provider able to attempt authentication, or skip authentication by simply returning null. If all implementations return null, the ProviderManager will throw a suitable exception.

Below is the spring bean configuration which can be used for setting up multiple authentication providers in your Spring application using Spring Security.

spring-security.xml

Sample 1:-

Sample 2:-

In the above sample configuration, both the declared authentication providers will be registered with authentication manager.

Page Visitors: 5534