Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c3edb50e80 | ||
|
|
aee1861630 | ||
|
|
4196b2531d | ||
|
|
dfaeacae92 | ||
|
|
b304c48dd1 | ||
|
|
d045534be6 | ||
|
|
56b923f5db | ||
|
|
f3e8231814 | ||
|
|
2ca04e654f | ||
|
|
149f4ab061 |
12
CHANGELOG.md
Normal file
12
CHANGELOG.md
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
## 0.7.3
|
||||||
|
|
||||||
|
### 增加
|
||||||
|
|
||||||
|
> 1,TsTokenConfig增加新的属性**ignorePaths**,用于通过路径忽略token;
|
||||||
|
> 2,PasswordUtils增加密码复杂度校验方法;
|
||||||
|
> 3,PasswordUtils.verifyPassword增加登录次数限制:10分钟内不能错误6次;
|
||||||
|
>
|
||||||
|
|
||||||
|
### 调整
|
||||||
|
|
||||||
|
> 1,TsTokenConfig中的**ignores**属性调整为**testMap**;
|
||||||
4
README.md
Normal file
4
README.md
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
## 杭州铁晟科技有限公司基础项目
|
||||||
|
|
||||||
|
更新日志可点击查看[changelog](./CHANGELOG.md ':include')
|
||||||
|
|
||||||
20
pom.xml
20
pom.xml
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-parent</artifactId>
|
<artifactId>springboot-parent</artifactId>
|
||||||
<version>0.7.0</version>
|
<version>0.7.3</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<name>springboot-parent</name>
|
<name>springboot-parent</name>
|
||||||
<description>杭州铁晟科技有限公司基础依赖</description>
|
<description>杭州铁晟科技有限公司基础依赖</description>
|
||||||
@@ -57,55 +57,55 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-database</artifactId>
|
<artifactId>springboot-database</artifactId>
|
||||||
<version>0.7.0</version>
|
<version>0.7.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-login</artifactId>
|
<artifactId>springboot-login</artifactId>
|
||||||
<version>0.7.0</version>
|
<version>0.7.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-web</artifactId>
|
<artifactId>springboot-web</artifactId>
|
||||||
<version>0.7.0</version>
|
<version>0.7.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-util</artifactId>
|
<artifactId>springboot-util</artifactId>
|
||||||
<version>0.7.0</version>
|
<version>0.7.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-platform</artifactId>
|
<artifactId>springboot-platform</artifactId>
|
||||||
<version>0.7.0</version>
|
<version>0.7.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-message</artifactId>
|
<artifactId>springboot-message</artifactId>
|
||||||
<version>0.7.0</version>
|
<version>0.7.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-encrypt</artifactId>
|
<artifactId>springboot-encrypt</artifactId>
|
||||||
<version>0.7.0</version>
|
<version>0.7.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-annotation</artifactId>
|
<artifactId>springboot-annotation</artifactId>
|
||||||
<version>0.7.0</version>
|
<version>0.7.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-poi</artifactId>
|
<artifactId>springboot-poi</artifactId>
|
||||||
<version>0.7.0</version>
|
<version>0.7.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-parent</artifactId>
|
<artifactId>springboot-parent</artifactId>
|
||||||
<version>0.7.0</version>
|
<version>0.7.3</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-ademo</artifactId>
|
<artifactId>springboot-ademo</artifactId>
|
||||||
|
|||||||
@@ -48,15 +48,13 @@ public class TestController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("/redirect")
|
@RequestMapping("/redirect")
|
||||||
@TokenIgnore
|
|
||||||
public void redirect(HttpServletResponse response) {
|
public void redirect(HttpServletResponse response) {
|
||||||
tsTokenConfig.validToken("eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE2NzYwMDY4NzUsImlkIjoiMSIsImVudmlyb25tZW50VHlwZSI6Im1vYmlsZSIsInNlcnZpY2UiOiJjb250ZXN0LXJlc2VydmUiLCJleHRyYSI6IiJ9.nsfxEFpCNHC7eNCS5DJXdu1VDdnHrTjSfgrozND70Lc", true);
|
// tsTokenConfig.validToken("eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE2NzYwMDY4NzUsImlkIjoiMSIsImVudmlyb25tZW50VHlwZSI6Im1vYmlsZSIsInNlcnZpY2UiOiJjb250ZXN0LXJlc2VydmUiLCJleHRyYSI6IiJ9.nsfxEFpCNHC7eNCS5DJXdu1VDdnHrTjSfgrozND70Lc", true);
|
||||||
// globalConfig.redirect("mobile", "/test", response);
|
// globalConfig.redirect("mobile", "/test", response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@RequestMapping("/send")
|
@RequestMapping("/send")
|
||||||
@TokenIgnore
|
|
||||||
public ApiResp<MessageReqResp> sendMessage() {
|
public ApiResp<MessageReqResp> sendMessage() {
|
||||||
MessageReqResp reqResp = aliyunSmsConfig.sendSms("13567116463", "SMS_154950909",
|
MessageReqResp reqResp = aliyunSmsConfig.sendSms("13567116463", "SMS_154950909",
|
||||||
JSONUtil.createObj().putOpt("code", "123456"));
|
JSONUtil.createObj().putOpt("code", "123456"));
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ platform:
|
|||||||
|
|
||||||
tiesheng:
|
tiesheng:
|
||||||
token:
|
token:
|
||||||
ignores:
|
test-map:
|
||||||
"1111":
|
"1111":
|
||||||
id: "1111"
|
id: "1111"
|
||||||
global:
|
global:
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-parent</artifactId>
|
<artifactId>springboot-parent</artifactId>
|
||||||
<version>0.7.0</version>
|
<version>0.7.3</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-annotation</artifactId>
|
<artifactId>springboot-annotation</artifactId>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-parent</artifactId>
|
<artifactId>springboot-parent</artifactId>
|
||||||
<version>0.7.0</version>
|
<version>0.7.3</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-database</artifactId>
|
<artifactId>springboot-database</artifactId>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-parent</artifactId>
|
<artifactId>springboot-parent</artifactId>
|
||||||
<version>0.7.0</version>
|
<version>0.7.3</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-encrypt</artifactId>
|
<artifactId>springboot-encrypt</artifactId>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-parent</artifactId>
|
<artifactId>springboot-parent</artifactId>
|
||||||
<version>0.7.0</version>
|
<version>0.7.3</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-login</artifactId>
|
<artifactId>springboot-login</artifactId>
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package com.tiesheng.login.config.token;
|
package com.tiesheng.login.config.token;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.tiesheng.annotation.token.TokenIgnore;
|
import com.tiesheng.annotation.token.TokenIgnore;
|
||||||
|
import com.tiesheng.util.ServletKit;
|
||||||
import org.aspectj.lang.JoinPoint;
|
import org.aspectj.lang.JoinPoint;
|
||||||
import org.aspectj.lang.annotation.Aspect;
|
import org.aspectj.lang.annotation.Aspect;
|
||||||
import org.aspectj.lang.annotation.Before;
|
import org.aspectj.lang.annotation.Before;
|
||||||
@@ -46,13 +48,18 @@ public class TsTokenAspect {
|
|||||||
@Before("methodArgs()")
|
@Before("methodArgs()")
|
||||||
public void before(JoinPoint joinPoint) {
|
public void before(JoinPoint joinPoint) {
|
||||||
|
|
||||||
|
// 过滤不要需要验证的接口(path)
|
||||||
|
String requestURI = ServletKit.getRequest().getRequestURI();
|
||||||
|
if (StrUtil.startWithAnyIgnoreCase(requestURI, tsTokenConfig.getIgnorePaths())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 过滤不要需要验证的接口(注解)
|
||||||
Object aThis = joinPoint.getTarget();
|
Object aThis = joinPoint.getTarget();
|
||||||
TokenIgnore annotation = aThis.getClass().getAnnotation(TokenIgnore.class);
|
TokenIgnore annotation = aThis.getClass().getAnnotation(TokenIgnore.class);
|
||||||
if (annotation != null) {
|
if (annotation != null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 过滤不要需要验证的接口
|
|
||||||
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
|
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
|
||||||
Method method = signature.getMethod();
|
Method method = signature.getMethod();
|
||||||
TokenIgnore apiTokenIgnore = method.getAnnotation(TokenIgnore.class);
|
TokenIgnore apiTokenIgnore = method.getAnnotation(TokenIgnore.class);
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.tiesheng.login.config.token;
|
package com.tiesheng.login.config.token;
|
||||||
|
|
||||||
|
|
||||||
import cn.hutool.core.date.DateUtil;
|
|
||||||
import cn.hutool.core.map.MapUtil;
|
import cn.hutool.core.map.MapUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.extra.servlet.ServletUtil;
|
import cn.hutool.extra.servlet.ServletUtil;
|
||||||
@@ -24,9 +23,10 @@ import java.util.Map;
|
|||||||
@ConfigurationProperties("tiesheng.token")
|
@ConfigurationProperties("tiesheng.token")
|
||||||
public class TsTokenConfig {
|
public class TsTokenConfig {
|
||||||
|
|
||||||
private Map<String, TokenBean> ignores = MapUtil.newHashMap();
|
private Map<String, TokenBean> testMap = MapUtil.newHashMap();
|
||||||
private String encryptKey = "%kIp9frQCu";
|
private String encryptKey = "%kIp9frQCu";
|
||||||
private Integer expireHours = 48;
|
private Integer expireHours = 48;
|
||||||
|
private String[] ignorePaths;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -57,11 +57,11 @@ public class TsTokenConfig {
|
|||||||
* @param token
|
* @param token
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public TokenBean isIgnored(String token) {
|
public TokenBean isTestToken(String token) {
|
||||||
if (ignores == null) {
|
if (testMap == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return ignores.get(token);
|
return testMap.get(token);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -83,7 +83,7 @@ public class TsTokenConfig {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public TokenBean validToken(String token, boolean thrExp) {
|
public TokenBean validToken(String token, boolean thrExp) {
|
||||||
TokenBean tokenBean = isIgnored(token);
|
TokenBean tokenBean = isTestToken(token);
|
||||||
if (tokenBean != null) {
|
if (tokenBean != null) {
|
||||||
return tokenBean;
|
return tokenBean;
|
||||||
}
|
}
|
||||||
@@ -101,7 +101,8 @@ public class TsTokenConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (tokenBean == null && thrExp) {
|
if (tokenBean == null && thrExp) {
|
||||||
throw new ApiException(StrUtil.isEmpty(token) ? "请先登录" : "登录过期,请重新登陆");
|
throw new ApiException(StrUtil.isEmpty(token) ? 110 : 112,
|
||||||
|
StrUtil.isEmpty(token) ? "请先登录" : "登录过期,请重新登陆");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tokenBean == null) {
|
if (tokenBean == null) {
|
||||||
@@ -116,12 +117,12 @@ public class TsTokenConfig {
|
|||||||
// setter\getter
|
// setter\getter
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
public Map<String, TokenBean> getIgnores() {
|
public Map<String, TokenBean> getTestMap() {
|
||||||
return ignores;
|
return testMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIgnores(Map<String, TokenBean> ignores) {
|
public void setTestMap(Map<String, TokenBean> testMap) {
|
||||||
this.ignores = ignores;
|
this.testMap = testMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getEncryptKey() {
|
public String getEncryptKey() {
|
||||||
@@ -139,4 +140,12 @@ public class TsTokenConfig {
|
|||||||
public void setExpireHours(Integer expireHours) {
|
public void setExpireHours(Integer expireHours) {
|
||||||
this.expireHours = expireHours;
|
this.expireHours = expireHours;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String[] getIgnorePaths() {
|
||||||
|
return ignorePaths;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIgnorePaths(String[] ignorePaths) {
|
||||||
|
this.ignorePaths = ignorePaths;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/login")
|
@RequestMapping("/login")
|
||||||
|
@TokenIgnore
|
||||||
public class LoginController {
|
public class LoginController {
|
||||||
|
|
||||||
|
|
||||||
@@ -56,7 +57,6 @@ public class LoginController {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@GetMapping("/unique/redirect")
|
@GetMapping("/unique/redirect")
|
||||||
@TokenIgnore
|
|
||||||
public void uniqueIndex(UniqueIndexDTO dto, HttpServletResponse response) {
|
public void uniqueIndex(UniqueIndexDTO dto, HttpServletResponse response) {
|
||||||
TokenBean tokenBean = tieshengLoginConfigurer.doLogin(new DoLoginInfo("unique_index_web",
|
TokenBean tokenBean = tieshengLoginConfigurer.doLogin(new DoLoginInfo("unique_index_web",
|
||||||
dto.getNo(), "web", dto.getTo(), dto.getInfo()));
|
dto.getNo(), "web", dto.getTo(), dto.getInfo()));
|
||||||
@@ -71,7 +71,6 @@ public class LoginController {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@PostMapping("/unique/index")
|
@PostMapping("/unique/index")
|
||||||
@TokenIgnore
|
|
||||||
public ApiResp<String> uniqueIndex(@RequestBody UniqueIndexDTO dto) {
|
public ApiResp<String> uniqueIndex(@RequestBody UniqueIndexDTO dto) {
|
||||||
TokenBean tokenBean = tieshengLoginConfigurer.doLogin(new DoLoginInfo("unique_index_web",
|
TokenBean tokenBean = tieshengLoginConfigurer.doLogin(new DoLoginInfo("unique_index_web",
|
||||||
dto.getNo(), "web", dto.getTo(), dto.getInfo()));
|
dto.getNo(), "web", dto.getTo(), dto.getInfo()));
|
||||||
@@ -94,7 +93,6 @@ public class LoginController {
|
|||||||
* @param response
|
* @param response
|
||||||
*/
|
*/
|
||||||
@GetMapping("/ding/index/{service}")
|
@GetMapping("/ding/index/{service}")
|
||||||
@TokenIgnore
|
|
||||||
public void dingIndex(@PathVariable String service, String extra, HttpServletResponse response) {
|
public void dingIndex(@PathVariable String service, String extra, HttpServletResponse response) {
|
||||||
if (StrUtil.isEmpty(extra)) {
|
if (StrUtil.isEmpty(extra)) {
|
||||||
extra = "";
|
extra = "";
|
||||||
@@ -118,7 +116,6 @@ public class LoginController {
|
|||||||
* @param service
|
* @param service
|
||||||
*/
|
*/
|
||||||
@RequestMapping("/ding/oauth2/{service}")
|
@RequestMapping("/ding/oauth2/{service}")
|
||||||
@TokenIgnore
|
|
||||||
public void dingOauth2(@PathVariable String service, CodeExtraDTO dto, HttpServletResponse response) {
|
public void dingOauth2(@PathVariable String service, CodeExtraDTO dto, HttpServletResponse response) {
|
||||||
String ddUserId = platformDingConfig.getUserIdByCode(service, dto.getCode());
|
String ddUserId = platformDingConfig.getUserIdByCode(service, dto.getCode());
|
||||||
DingUserInfo dingUserInfo = platformDingConfig.topapiV2UserGet(service, ddUserId);
|
DingUserInfo dingUserInfo = platformDingConfig.topapiV2UserGet(service, ddUserId);
|
||||||
@@ -136,7 +133,6 @@ public class LoginController {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@GetMapping("/ding/jssdk/{service}")
|
@GetMapping("/ding/jssdk/{service}")
|
||||||
@TokenIgnore
|
|
||||||
public ApiResp<DingJsapiSignature> dingJssdk(@PathVariable String service, String url) {
|
public ApiResp<DingJsapiSignature> dingJssdk(@PathVariable String service, String url) {
|
||||||
DingJsapiSignature jsapiSignature = platformDingConfig.createJsapiSignature(service, url);
|
DingJsapiSignature jsapiSignature = platformDingConfig.createJsapiSignature(service, url);
|
||||||
return ApiResp.respOK(jsapiSignature);
|
return ApiResp.respOK(jsapiSignature);
|
||||||
@@ -154,7 +150,6 @@ public class LoginController {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@RequestMapping("/wxmp/index/{service}")
|
@RequestMapping("/wxmp/index/{service}")
|
||||||
@TokenIgnore
|
|
||||||
public void wxmpIndex(@PathVariable String service, String extra, HttpServletResponse response) throws IOException {
|
public void wxmpIndex(@PathVariable String service, String extra, HttpServletResponse response) throws IOException {
|
||||||
if (StrUtil.isEmpty(extra)) {
|
if (StrUtil.isEmpty(extra)) {
|
||||||
extra = "";
|
extra = "";
|
||||||
@@ -169,7 +164,6 @@ public class LoginController {
|
|||||||
* 微信授权回调
|
* 微信授权回调
|
||||||
*/
|
*/
|
||||||
@RequestMapping("/wxmp/oauth2/{service}")
|
@RequestMapping("/wxmp/oauth2/{service}")
|
||||||
@TokenIgnore
|
|
||||||
public void wxmpOauth2(@PathVariable String service, CodeExtraDTO dto, HttpServletResponse response) {
|
public void wxmpOauth2(@PathVariable String service, CodeExtraDTO dto, HttpServletResponse response) {
|
||||||
WxUserInfo wxUserInfo = platformWxmpConfig.getOAuth2AccessToken(service, dto.getCode());
|
WxUserInfo wxUserInfo = platformWxmpConfig.getOAuth2AccessToken(service, dto.getCode());
|
||||||
TokenBean tokenBean = tieshengLoginConfigurer.doLogin(new DoLoginInfo(wxUserInfo.getAppId(),
|
TokenBean tokenBean = tieshengLoginConfigurer.doLogin(new DoLoginInfo(wxUserInfo.getAppId(),
|
||||||
@@ -185,7 +179,6 @@ public class LoginController {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@GetMapping("/wxmp/jssdk/{service}")
|
@GetMapping("/wxmp/jssdk/{service}")
|
||||||
@TokenIgnore
|
|
||||||
public ApiResp<WxJsapiSignature> wxmpJssdk(@PathVariable String service, String url) {
|
public ApiResp<WxJsapiSignature> wxmpJssdk(@PathVariable String service, String url) {
|
||||||
WxJsapiSignature jsapiSignature = platformWxmpConfig.createJsapiSignature(service, url);
|
WxJsapiSignature jsapiSignature = platformWxmpConfig.createJsapiSignature(service, url);
|
||||||
return ApiResp.respOK(jsapiSignature);
|
return ApiResp.respOK(jsapiSignature);
|
||||||
@@ -201,7 +194,6 @@ public class LoginController {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@RequestMapping("/wxmini/index/{service}")
|
@RequestMapping("/wxmini/index/{service}")
|
||||||
@TokenIgnore
|
|
||||||
public ApiResp<WxminiLoginVo> wxminiIndex(@PathVariable String service, String code) {
|
public ApiResp<WxminiLoginVo> wxminiIndex(@PathVariable String service, String code) {
|
||||||
String openid = platformWxminiConfig.jscode2session(service, code);
|
String openid = platformWxminiConfig.jscode2session(service, code);
|
||||||
WxConfigBean configBean = platformWxminiConfig.getConfigBean(service);
|
WxConfigBean configBean = platformWxminiConfig.getConfigBean(service);
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-parent</artifactId>
|
<artifactId>springboot-parent</artifactId>
|
||||||
<version>0.7.0</version>
|
<version>0.7.3</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-message</artifactId>
|
<artifactId>springboot-message</artifactId>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-parent</artifactId>
|
<artifactId>springboot-parent</artifactId>
|
||||||
<version>0.7.0</version>
|
<version>0.7.3</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-platform</artifactId>
|
<artifactId>springboot-platform</artifactId>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-parent</artifactId>
|
<artifactId>springboot-parent</artifactId>
|
||||||
<version>0.7.0</version>
|
<version>0.7.3</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-poi</artifactId>
|
<artifactId>springboot-poi</artifactId>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-parent</artifactId>
|
<artifactId>springboot-parent</artifactId>
|
||||||
<version>0.7.0</version>
|
<version>0.7.3</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-util</artifactId>
|
<artifactId>springboot-util</artifactId>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.tiesheng.util;
|
package com.tiesheng.util;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.NumberUtil;
|
||||||
import cn.hutool.core.util.RandomUtil;
|
import cn.hutool.core.util.RandomUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.crypto.SecureUtil;
|
import cn.hutool.crypto.SecureUtil;
|
||||||
@@ -21,6 +22,17 @@ public class PasswordUtils {
|
|||||||
return prefix + SecureUtil.sha1(password);
|
return prefix + SecureUtil.sha1(password);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 密码复杂度校验
|
||||||
|
*
|
||||||
|
* @param userPassword
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static boolean verifyComplexity(String userPassword) {
|
||||||
|
String password = "^(?![A-Za-z0-9]+$)(?![a-z0-9\\W]+$)(?![A-Za-z\\W]+$)(?![A-Z0-9\\W]+$)[a-zA-Z0-9\\W]{8,}$";
|
||||||
|
return userPassword.matches(password);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 验证密码
|
* 验证密码
|
||||||
@@ -30,12 +42,18 @@ public class PasswordUtils {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static void verifyPassword(String userInput, String encrypted) {
|
public static void verifyPassword(String userInput, String encrypted) {
|
||||||
|
String clientIp = ServletKit.getClientIP();
|
||||||
String userEncrypted = buildPassword(userInput);
|
String userEncrypted = buildPassword(userInput);
|
||||||
|
|
||||||
userEncrypted = StrUtil.subSuf(userEncrypted, PREFIX_SIZE);
|
userEncrypted = StrUtil.subSuf(userEncrypted, PREFIX_SIZE);
|
||||||
encrypted = StrUtil.subSuf(encrypted, PREFIX_SIZE);
|
encrypted = StrUtil.subSuf(encrypted, PREFIX_SIZE);
|
||||||
|
|
||||||
if (!StrUtil.equals(userEncrypted, encrypted)) {
|
if (!StrUtil.equals(userEncrypted, encrypted)) {
|
||||||
|
int num = NumberUtil.parseInt(TimedCacheHelper.getTimedCache().get(clientIp, false));
|
||||||
|
if (num > 5) {
|
||||||
|
throw new ApiException("登录失败已达6次,请10分钟后再试");
|
||||||
|
}
|
||||||
|
TimedCacheHelper.getTimedCache().put(clientIp, String.valueOf(num + 1), 10 * 60 * 1000);
|
||||||
throw new ApiException("账号或密码错误");
|
throw new ApiException("账号或密码错误");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,5 +20,14 @@ public class ServletKit extends ServletUtil {
|
|||||||
return attributes.getRequest();
|
return attributes.getRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取客户端IP
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String getClientIP() {
|
||||||
|
return getClientIP(getRequest());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-parent</artifactId>
|
<artifactId>springboot-parent</artifactId>
|
||||||
<version>0.7.0</version>
|
<version>0.7.3</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-web</artifactId>
|
<artifactId>springboot-web</artifactId>
|
||||||
|
|||||||
@@ -22,6 +22,9 @@ public class DesensitizeValueFilter implements ValueFilter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Field field = ClassUtil.getDeclaredField(object.getClass(), name);
|
Field field = ClassUtil.getDeclaredField(object.getClass(), name);
|
||||||
|
if (ObjectUtil.isEmpty(field)) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
Desensitize desensitize = field.getAnnotation(Desensitize.class);
|
Desensitize desensitize = field.getAnnotation(Desensitize.class);
|
||||||
if (String.class != field.getType() || ObjectUtil.isEmpty(desensitize)) {
|
if (String.class != field.getType() || ObjectUtil.isEmpty(desensitize)) {
|
||||||
return value;
|
return value;
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ public class CoreLogService extends TsServiceBase<CoreLogOperationMapper, CoreLo
|
|||||||
String ip = ServletUtil.getClientIP(request);
|
String ip = ServletUtil.getClientIP(request);
|
||||||
|
|
||||||
CoreLogLogin login = new CoreLogLogin();
|
CoreLogLogin login = new CoreLogLogin();
|
||||||
login.setUserId(platformUnique.getUserId());
|
login.setUserId(tokenBean.getId());
|
||||||
login.setPlatform(platformUnique.getPlatform());
|
login.setPlatform(platformUnique.getPlatform());
|
||||||
|
|
||||||
RequestUserInfo requestUserInfo = tieshengWebConfigurer.getCurrentUserName(tokenBean);
|
RequestUserInfo requestUserInfo = tieshengWebConfigurer.getCurrentUserName(tokenBean);
|
||||||
|
|||||||
Reference in New Issue
Block a user