ucard login
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.newyetai.security.config;
|
||||
|
||||
import com.newyetai.security.ucard.UcardAuthenticationProvider;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurationPackage;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
@@ -84,5 +85,11 @@ public class SecurityConfiguration {
|
||||
SsbAuthenticationProvider ssbAuthenticationProvider(UserLoginService userLoginService) {
|
||||
return new SsbAuthenticationProvider(userLoginService);
|
||||
}
|
||||
|
||||
|
||||
@Bean
|
||||
@ConditionalOnBean(UserLoginService.class)
|
||||
UcardAuthenticationProvider ucardAuthenticationProvider(UserLoginService userLoginService) {
|
||||
return new UcardAuthenticationProvider(userLoginService);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.newyetai.security.config;
|
||||
|
||||
import com.newyetai.security.ucard.UcardAuthenticationFilter;
|
||||
import com.newyetai.security.ucard.UcardAuthenticationProvider;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.BooleanUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -43,7 +45,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* security配置
|
||||
*
|
||||
*
|
||||
* @author on 2019-11-05
|
||||
*/
|
||||
@Slf4j
|
||||
@@ -79,6 +81,9 @@ public class WebSecurityConfigurer extends WebSecurityConfigurerAdapter {
|
||||
@Autowired
|
||||
private SsbAuthenticationProvider ssbAuthenticationProvider;
|
||||
|
||||
@Autowired(required = false)
|
||||
private UcardAuthenticationProvider ucardAuthenticationProvider;
|
||||
|
||||
@Autowired
|
||||
private SwaggerConfig swaggerConfig;
|
||||
|
||||
@@ -92,9 +97,10 @@ public class WebSecurityConfigurer extends WebSecurityConfigurerAdapter {
|
||||
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
|
||||
// 添加cas认证提供者
|
||||
auth.authenticationProvider(upasswordAuthenticationProvider)
|
||||
.authenticationProvider(mobileAuthenticationProvider)
|
||||
.authenticationProvider(tokenAuthenticationProvider)
|
||||
.authenticationProvider(ssbAuthenticationProvider)
|
||||
.authenticationProvider(mobileAuthenticationProvider)
|
||||
.authenticationProvider(tokenAuthenticationProvider)
|
||||
.authenticationProvider(ssbAuthenticationProvider)
|
||||
.authenticationProvider(ucardAuthenticationProvider);
|
||||
;
|
||||
}
|
||||
|
||||
@@ -146,6 +152,8 @@ public class WebSecurityConfigurer extends WebSecurityConfigurerAdapter {
|
||||
http.addFilterAfter(mobileAuthenticationFilter(), UpasswordAuthenticationFilter.class);
|
||||
http.addFilterAfter(tokenAuthenticationFilter(), UpasswordAuthenticationFilter.class);
|
||||
http.addFilterAfter(ssbAuthenticationFilter(), UpasswordAuthenticationFilter.class);
|
||||
http.addFilterAfter(ucardAuthenticationFilter(), UpasswordAuthenticationFilter.class);
|
||||
|
||||
|
||||
// 禁用CSRF
|
||||
http.csrf().disable();
|
||||
@@ -171,14 +179,14 @@ public class WebSecurityConfigurer extends WebSecurityConfigurerAdapter {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private JwtAuthenticationTokenFilter createJwtAuthenticationTokenFilter() {
|
||||
return new JwtAuthenticationTokenFilter(securityProperties);
|
||||
}
|
||||
|
||||
/**
|
||||
* 拦截器
|
||||
*
|
||||
*
|
||||
* @return
|
||||
* @throws Exception
|
||||
* @author sr on 2019-11-28
|
||||
@@ -196,11 +204,11 @@ public class WebSecurityConfigurer extends WebSecurityConfigurerAdapter {
|
||||
|
||||
/**
|
||||
* 手机号登录请求过滤器
|
||||
*
|
||||
*
|
||||
* @param authenticationManager
|
||||
* @return
|
||||
* @author sr on 2020-06-04
|
||||
* @throws Exception
|
||||
* @author sr on 2020-06-04
|
||||
*/
|
||||
private MobileAuthenticationFilter mobileAuthenticationFilter() throws Exception {
|
||||
MobileAuthenticationFilter filter = new MobileAuthenticationFilter();
|
||||
@@ -216,9 +224,10 @@ public class WebSecurityConfigurer extends WebSecurityConfigurerAdapter {
|
||||
|
||||
/**
|
||||
* 账号密码
|
||||
*
|
||||
* @return
|
||||
* @throws Exception
|
||||
* @author sr on 2021-06-22
|
||||
* @author sr on 2021-06-22
|
||||
*/
|
||||
private UpasswordAuthenticationFilter upasswordAuthenticationFilter() throws Exception {
|
||||
UpasswordAuthenticationFilter filter = new UpasswordAuthenticationFilter();
|
||||
@@ -228,9 +237,10 @@ public class WebSecurityConfigurer extends WebSecurityConfigurerAdapter {
|
||||
|
||||
/**
|
||||
* 临时token
|
||||
*
|
||||
* @return
|
||||
* @throws Exception
|
||||
* @author sr on 2021-06-22
|
||||
* @author sr on 2021-06-22
|
||||
*/
|
||||
private TokenAuthenticationFilter tokenAuthenticationFilter() throws Exception {
|
||||
TokenAuthenticationFilter filter = new TokenAuthenticationFilter();
|
||||
@@ -244,4 +254,17 @@ public class WebSecurityConfigurer extends WebSecurityConfigurerAdapter {
|
||||
return filter;
|
||||
}
|
||||
|
||||
/**
|
||||
* 身份证登录
|
||||
* @return
|
||||
* @throws Exception
|
||||
* @author sr on 2024-09-23
|
||||
*/
|
||||
private UcardAuthenticationFilter ucardAuthenticationFilter() throws Exception {
|
||||
UcardAuthenticationFilter filter = new UcardAuthenticationFilter();
|
||||
addHandler(filter);
|
||||
return filter;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user