|
@ -1,5 +1,6 @@ |
|
|
package com.research.framework.config; |
|
|
package com.research.framework.config; |
|
|
|
|
|
|
|
|
|
|
|
import com.research.framework.security.provider.DmsUserAuthenticationProvider; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.context.annotation.Bean; |
|
|
import org.springframework.context.annotation.Bean; |
|
|
import org.springframework.context.annotation.Configuration; |
|
|
import org.springframework.context.annotation.Configuration; |
|
@ -75,7 +76,7 @@ public class SecurityConfig |
|
|
DaoAuthenticationProvider daoAuthenticationProvider = new DaoAuthenticationProvider(); |
|
|
DaoAuthenticationProvider daoAuthenticationProvider = new DaoAuthenticationProvider(); |
|
|
daoAuthenticationProvider.setUserDetailsService(userDetailsService); |
|
|
daoAuthenticationProvider.setUserDetailsService(userDetailsService); |
|
|
daoAuthenticationProvider.setPasswordEncoder(bCryptPasswordEncoder()); |
|
|
daoAuthenticationProvider.setPasswordEncoder(bCryptPasswordEncoder()); |
|
|
return new ProviderManager(daoAuthenticationProvider); |
|
|
return new ProviderManager(daoAuthenticationProvider, dmsUserAuthenticationProvider()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -111,7 +112,7 @@ public class SecurityConfig |
|
|
.authorizeHttpRequests((requests) -> { |
|
|
.authorizeHttpRequests((requests) -> { |
|
|
permitAllUrl.getUrls().forEach(url -> requests.antMatchers(url).permitAll()); |
|
|
permitAllUrl.getUrls().forEach(url -> requests.antMatchers(url).permitAll()); |
|
|
// 对于登录login 注册register 验证码captchaImage 允许匿名访问
|
|
|
// 对于登录login 注册register 验证码captchaImage 允许匿名访问
|
|
|
requests.antMatchers("/login", "/register", "/captchaImage").permitAll() |
|
|
requests.antMatchers("/login", "/register", "/captchaImage", "web/login", "web/loginSimple").permitAll() |
|
|
// 静态资源,可匿名访问
|
|
|
// 静态资源,可匿名访问
|
|
|
.antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll() |
|
|
.antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll() |
|
|
.antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll() |
|
|
.antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll() |
|
@ -136,4 +137,25 @@ public class SecurityConfig |
|
|
{ |
|
|
{ |
|
|
return new BCryptPasswordEncoder(); |
|
|
return new BCryptPasswordEncoder(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Bean |
|
|
|
|
|
public DmsUserAuthenticationProvider dmsUserAuthenticationProvider(){ |
|
|
|
|
|
return new DmsUserAuthenticationProvider(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// @Override
|
|
|
|
|
|
// protected void configure(AuthenticationManagerBuilder auth) throws Exception {
|
|
|
|
|
|
// //填报端认证
|
|
|
|
|
|
// auth.authenticationProvider(dmsUserAuthenticationProvider());
|
|
|
|
|
|
// //用户名密码认证
|
|
|
|
|
|
// auth.userDetailsService(userDetailsService).passwordEncoder(bCryptPasswordEncoder());
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
@Bean |
|
|
|
|
|
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { |
|
|
|
|
|
http |
|
|
|
|
|
// ... 其他配置
|
|
|
|
|
|
.authenticationProvider(dmsUserAuthenticationProvider()); // 注入自定义 Provider
|
|
|
|
|
|
return http.build(); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|