ucard login

This commit is contained in:
ran.shang
2025-08-12 10:41:06 +08:00
parent 4526fc1cf8
commit bf59ce0a10
11 changed files with 290 additions and 35 deletions

View File

@@ -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;
}
}