spring-security java config: Cómo configurar varias instancias de AuthenticationManager
Yo suelo:
arranque de primavera: 1.1.7seguridad de resorte: 4.0.0.M2spring-fmk: 4.1.1.RELEASETodo está configurado con Java Config (incluida Spring-Security)
Estoy trabajando en un proyecto de servidor web donde se utiliza la autenticación: el encabezado básico base64Gibberish para autenticar a los usuarios.
El problema es que, dependiendo del URI, elAuthenticationManager
es diferente (porque necesito 2 diferentesUserDetailsService
.
He intentado múltiples extensiones deWebSecurityConfigurerAdapter
con
@Override
@Bean( name = "authManager1" )
public AuthenticationManager authenticationManagerBean() throws Exception
@Override
@Bean( name = "authManager2" )
public AuthenticationManager authenticationManagerBean() throws Exception
en vano
Siempre obtengo:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'springSecurityFilterChain'
defined in class path resource [org/springframework/security/config/annotation/web/configuration/WebSecurityConfiguration.class]: Instantiation of bean failed;
nested exception is org.springframework.beans.factory.BeanDefinitionStoreException:
Factory method [public javax.servlet.Filter org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration.springSecurityFilterChain() throws java.lang.Exception]
threw exception; nested exception is java.lang.IllegalArgumentException:
Expecting to only find a single bean for type interface org.springframework.security.authentication.AuthenticationManager,
but found [authManager1, authManager2]
Como tengo varias cadenas de filtros de seguridad, ¿cómo puedo "decir" a spring-security que inyecte diferentes AuthenticationManager en diferentes cadenas de filtros de seguridad?
Gracias de antemano P.