Skip to content

Commit 4bcfd25

Browse files
committed
改为构造函数注入
1 parent 0aec52e commit 4bcfd25

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

tang-framework/src/main/java/com/tang/framework/config/SecurityConfig.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@
3232
@EnableMethodSecurity
3333
public class SecurityConfig {
3434

35+
private final List<AuthenticationProvider> providers;
36+
37+
public SecurityConfig(List<AuthenticationProvider> providers) {
38+
this.providers = providers;
39+
}
40+
3541
@Bean
3642
public SecurityFilterChain securityFilterChain(HttpSecurity httpSecurity, AuthenticationEntryPoint authenticationEntryPoint,
3743
JwtAuthenticationTokenFilter jwtAuthenticationTokenFilter, LogoutSuccessHandler logoutSuccessHandler) throws Exception {
@@ -60,9 +66,7 @@ public SecurityFilterChain securityFilterChain(HttpSecurity httpSecurity, Authen
6066
}
6167

6268
@Bean
63-
public AuthenticationManager authenticationManager(AuthenticationProvider usernameAuthenticationProvider, AuthenticationProvider emailAuthenticationProvider,
64-
AuthenticationProvider gitHubAuthenticationProvider) {
65-
var providers = List.of(usernameAuthenticationProvider, emailAuthenticationProvider, gitHubAuthenticationProvider);
69+
public AuthenticationManager authenticationManager() {
6670
return new ProviderManager(providers);
6771
}
6872

0 commit comments

Comments
 (0)