Delegiert ist.
Code: Select all
DaoAuthenticationProvider
[*]
Code: Select all
TwoFactorAuthenticationProvider
Code: Select all
@Configuration
@EnableWebSecurity
@EnableMethodSecurity
public class SecurityConfiguration {
@Bean
public AuthenticationManager authenticationManager(UserDetailsService userDetailsService,
PasswordEncoder passwordEncoder,
HttpSecurity http) throws Exception {
var singleFactorProvider = new DaoAuthenticationProvider(passwordEncoder);
singleFactorProvider.setUserDetailsService(userDetailsService);
var twoFactorProvider = new TwoFactorAuthenticationProvider(passwordEncoder, userDetailsService);
return http.getSharedObject(AuthenticationManagerBuilder.class)
.authenticationProvider(singleFactorProvider)
.authenticationProvider(twoFactorProvider)
.build();
}
@Bean
public SecurityFilterChain configure(AuthenticationManager authenticationManager,
HttpSecurity http) throws Exception {
// The real class has additional configuration, but I've omitted it as it's
// not relevant to the question
return http.authenticationManager(authenticationManager).build()
}
}
< /code>
Wenn ich versuche, einen Verweis auf diesen Authentifizierungsmanager zu erhalten, erhalte ich stattdessen die Standardimplementierung. Ich kann den AuthenticationManager
- die Authentifizierungskonfiguration und aufrufen AuthenticationManager ()
- Injizieren der Authentifizierungsmanager (/Code>
Ins "in der Authentifizierungsmanager (/code> - " injiziert, in denen die Authentifizierung der Authentifizierung der Authentifizierung der AuthenticationManitern (/codes>