В моем приложении Spring Boot я вывел свой пользовательский MyProviderManager
, где я хотел бы управлять логическим c внутренним методом authenticate
public Authentication authenticate(Authentication authentication) {
// instead of iterating in the AuthenticationProvider list one by one
// I'd rather choose the right AuthenticationProvider based on the currently requested URL path
RequestDetails requestDetails = authentication.getDetails();
if ("/ad/sso".equals(requestDetails.getPath())) {
return adAuthenticationProvider.authenticate(authentication);
} else if ("/saml/sso".equals(requestDetails.getPath())) {
return samlAuthenticationProvider.authenticate(authentication);
} else if ("/oidc/sso".equals(requestDetails.getPath())) {
return oidcAuthenticationProvider.authenticate(authentication);
} else {
return ldapAuthenticationProvider.authenticate(authentication);
}
return null;
}
Тем не менее, теперь мне трудно внедрить мой пользовательский MyProviderManager
с AuthenticationManagerBuilder , так что метод performBuild
() в AuthenticationManagerBuilder вернется MyProviderManager
вместо используемого по умолчанию в Spring Security
Я даже пытался выдать свой пользовательский MyAuthenticationManagerBuilder
exends AuthenticationManagerBuilder
и переопределить performBuild
() , но я столкнулся с той же проблемой, как внедрить мой пользовательский AuthenticationManagerBuilder в Spring Boot
Очень важно, если кто-то может пролить свет на проблемы здесь или есть лучшие альтернативные идеи для решения моих особых требований