Skip to content

Commit

Permalink
改为构造函数注入
Browse files Browse the repository at this point in the history
  • Loading branch information
tangllty committed Dec 1, 2023
1 parent 0aec52e commit 4bcfd25
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@
@EnableMethodSecurity
public class SecurityConfig {

private final List<AuthenticationProvider> providers;

public SecurityConfig(List<AuthenticationProvider> providers) {
this.providers = providers;
}

@Bean
public SecurityFilterChain securityFilterChain(HttpSecurity httpSecurity, AuthenticationEntryPoint authenticationEntryPoint,
JwtAuthenticationTokenFilter jwtAuthenticationTokenFilter, LogoutSuccessHandler logoutSuccessHandler) throws Exception {
Expand Down Expand Up @@ -60,9 +66,7 @@ public SecurityFilterChain securityFilterChain(HttpSecurity httpSecurity, Authen
}

@Bean
public AuthenticationManager authenticationManager(AuthenticationProvider usernameAuthenticationProvider, AuthenticationProvider emailAuthenticationProvider,
AuthenticationProvider gitHubAuthenticationProvider) {
var providers = List.of(usernameAuthenticationProvider, emailAuthenticationProvider, gitHubAuthenticationProvider);
public AuthenticationManager authenticationManager() {
return new ProviderManager(providers);
}

Expand Down

0 comments on commit 4bcfd25

Please sign in to comment.