新增放行路径多例配置
This commit is contained in:
parent
fe40966c0f
commit
9767f49a06
@ -7,6 +7,8 @@ import ink.wgink.login.base.security.user.UserSecurityConfig;
|
|||||||
import ink.wgink.login.base.service.user.UserDetailServiceImpl;
|
import ink.wgink.login.base.service.user.UserDetailServiceImpl;
|
||||||
import ink.wgink.login.base.service.user.UserLoginService;
|
import ink.wgink.login.base.service.user.UserLoginService;
|
||||||
import ink.wgink.properties.BaseProperties;
|
import ink.wgink.properties.BaseProperties;
|
||||||
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
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.security.authentication.AuthenticationManager;
|
import org.springframework.security.authentication.AuthenticationManager;
|
||||||
@ -33,9 +35,35 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
|
|||||||
private UserLoginService userLoginService;
|
private UserLoginService userLoginService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private PasswordEncoder passwordEncoder;
|
private PasswordEncoder passwordEncoder;
|
||||||
|
/**
|
||||||
|
* 默认放行配置
|
||||||
|
*/
|
||||||
|
private String[] defaultAntMatchers = {
|
||||||
|
baseProperties.getLoginUrl(),
|
||||||
|
baseProperties.getLoginProcess(),
|
||||||
|
baseProperties.getLoginFailure(),
|
||||||
|
"/oauth/**",
|
||||||
|
"/oauth_client/**",
|
||||||
|
"/app/**",
|
||||||
|
"/approute/**",
|
||||||
|
"/wechat/**",
|
||||||
|
"/wechat/route/**",
|
||||||
|
"/wechat-miniapp/**",
|
||||||
|
"/route/file/**",
|
||||||
|
"/api/sms/getverificationcode/*",
|
||||||
|
"/api/user/getsignintype/**"
|
||||||
|
};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void configure(HttpSecurity http) throws Exception {
|
protected void configure(HttpSecurity http) throws Exception {
|
||||||
|
String assetsMatchers = baseProperties.getAssetsMatchers();
|
||||||
|
String[] fullAntMatchers;
|
||||||
|
if (!StringUtils.isBlank(assetsMatchers)) {
|
||||||
|
String[] assetsMatchersArray = baseProperties.getAssetsMatchers().split(",");
|
||||||
|
fullAntMatchers = ArrayUtils.addAll(defaultAntMatchers, assetsMatchers);
|
||||||
|
} else {
|
||||||
|
fullAntMatchers = defaultAntMatchers;
|
||||||
|
}
|
||||||
LoginFailureHandler loginFailureHandler = new LoginFailureHandler(baseProperties.getLoginFailure());
|
LoginFailureHandler loginFailureHandler = new LoginFailureHandler(baseProperties.getLoginFailure());
|
||||||
http
|
http
|
||||||
.formLogin()
|
.formLogin()
|
||||||
@ -52,20 +80,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
|
|||||||
.disable()
|
.disable()
|
||||||
.and()
|
.and()
|
||||||
.authorizeRequests()
|
.authorizeRequests()
|
||||||
.antMatchers(baseProperties.getAssetsMatchers(),
|
.antMatchers(fullAntMatchers)
|
||||||
baseProperties.getLoginUrl(),
|
|
||||||
baseProperties.getLoginProcess(),
|
|
||||||
baseProperties.getLoginFailure(),
|
|
||||||
"/oauth/**",
|
|
||||||
"/oauth_client/**",
|
|
||||||
"/app/**",
|
|
||||||
"/approute/**",
|
|
||||||
"/wechat/**",
|
|
||||||
"/wechat/route/**",
|
|
||||||
"/wechat-miniapp/**",
|
|
||||||
"/route/file/**",
|
|
||||||
"/api/sms/getverificationcode/*",
|
|
||||||
"/api/user/getsignintype/**")
|
|
||||||
.permitAll()
|
.permitAll()
|
||||||
.and()
|
.and()
|
||||||
.authorizeRequests()
|
.authorizeRequests()
|
||||||
|
Loading…
Reference in New Issue
Block a user