에 따라 여러 인증 공급자를 선택할 나는 같은 내 응용 프로그램을 구성한봄 부팅/봄 보안 경로
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests().antMatchers("/api/v1").authenticated();
http.authorizeRequests().antMatchers("/api/v2").authenticated();
}
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.authenticationProvider(provider1);
auth.authenticationProvider(provider2);
}
내가 호출되는 /api/v2
provider1
를 호출하는 경우 지금 무슨 일하고 예외를 발생 또는 false를 반환하지 않는 경우 만 전화를받을 provider2
않습니다.
// In org.springframework.security.authentication.ProviderManager
for (AuthenticationProvider provider : getProviders()) {
try {
result = provider.authenticate(authentication);
if (result != null) {
copyDetails(authentication, result);
break;
}
}
...
...
}
어떻게 내가 /api/v2
에 충돌하는 경우에만 provider2
가 호출되는 그래서 할 수 있습니까? 이 같은
뭔가 :
http.authorizeRequests().antMatchers("/api/v2")
.authenticated().authenticationProvider(provider2);
(나는 HttpSecurity
에 authenticationProvider
가 알고있는, 그러나,이 AuthenticationManagerBuilder#authenticationProvider
전화로 정확한 동일)
다음은 [맞춤 인증 필터] (http://stackoverflow.com/a/27564349/873590)의 예입니다. – dsep