Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple Authentication Providers in Spring Security

I have configured two authentication providers in my Spring Security config:

   <security:authentication-manager>       <security:authentication-provider ref="XProvider" />       <security:authentication-provider ref="YProvider" />    </security:authentication-manager> 

Does spring security evaluate both providers? Or does it stop to evaluate if one of them fails? If not, How to make it stop?

Thanks.

like image 588
ankurvsoni Avatar asked Feb 15 '12 23:02

ankurvsoni


People also ask

Can we have multiple WebSecurityConfigurerAdapter?

When using Java configuration, the way to define multiple security realms is to have multiple @Configuration classes that extend the WebSecurityConfigurerAdapter base class – each with its own security configuration. These classes can be static and placed inside the main config.

What is authentication provider in Spring Security?

The Authentication Provider Spring Security provides a variety of options for performing authentication. These options follow a simple contract; an Authentication request is processed by an AuthenticationProvider, and a fully authenticated object with full credentials is returned.


1 Answers

You can specify as many providers as you want. They will be checked in the same order you declared them inside the authentication-manager tag.

Once a successful authentication is made, it will stop polling the providers. If any provider throws an AccountStatusException it will also break the polling.

like image 183
José Lecaros Avatar answered Sep 18 '22 07:09

José Lecaros