Merge branch '1.x' into tmp2
# Conflicts: # README.md # UPDATE.md # doc/MENU.md # pom.xml # yexuejc-springboot-base/pom.xml
@@ -9,7 +9,7 @@
|
||||
|
||||
### 内部集成
|
||||
#
|
||||
* [2.0.3新增 集成security登录](SECURITY.md)
|
||||
|
||||
* [(2.0.3)新增 集成security多方登录](SECURITY.md)
|
||||
单独使用例子工程:[https://github.com/yexuejc/springboot-security-login-simple](https://github.com/yexuejc/springboot-security-login-simple)
|
||||
* [1.0.6新增 针对API请求安全解决方案](PARAMS_RSA_DECRYPT_ENCRYPT.md)<br/>
|
||||
* [1.0.6新增 加密功能](PARAMS_RSA_DECRYPT_ENCRYPT.md)
|
||||
|
@@ -1,5 +1,7 @@
|
||||
Security框架封装集成登录 使用指南
|
||||
Security框架封装集成多方登录 使用指南
|
||||
-------------
|
||||
#### 先上[效果图](Securtity效果图.md)
|
||||
|
||||
单独使用例子工程:[https://github.com/yexuejc/springboot-security-login-simple](https://github.com/yexuejc/springboot-security-login-simple)
|
||||
* 本项目依赖不向下传递
|
||||
|
||||
@@ -15,7 +17,8 @@ Security框架封装集成登录 使用指南
|
||||
</dependencies>
|
||||
```
|
||||
> **相关文件说明** 所有核心文件都在 com.yexuejc.springboot.base.security 包下
|
||||
|
||||
#### 现附上系统实现逻辑图
|
||||

|
||||
|
||||
1.com.yexuejc.springboot.base.security.SecurityConfig
|
||||
<br/>
|
||||
@@ -26,6 +29,38 @@ Security框架封装集成登录 使用指南
|
||||
* 继承configure(HttpSecurity http) 完善更多security过滤配置
|
||||
* 例子[com.yexuejc.springboot.base.security.MySecurityConfig](../yexuejc-springboot-base/src/test/java/com/yexuejc/springboot/base/security/MySecurityConfig.java)
|
||||
|
||||
#### 注: 代码中抛出的相关异常拦截在filter.setAuthenticationFailureHandler()中处理,参考[MySecurityConfig](../yexuejc-springboot-base/src/test/java/com/yexuejc/springboot/base/security/MySecurityConfig.java)
|
||||
```
|
||||
filter.setAuthenticationFailureHandler((request, response, exception) -> {
|
||||
response.setContentType("application/json;charset=UTF-8");
|
||||
response.setStatus(HttpStatus.UNAUTHORIZED.value());
|
||||
Resps resps = new Resps();
|
||||
if (exception instanceof DisabledException) {
|
||||
resps.setErr(RespsConsts.CODE_FAIL, new String[]{BizConsts.BASE_IS_LOCK_MSG});
|
||||
} else if (exception instanceof AccountExpiredException) {
|
||||
resps.setErr(RespsConsts.CODE_FAIL, new String[]{BizConsts.BASE_IS_EXPIRE_MSG});
|
||||
} else if (exception instanceof CredentialsExpiredException) {
|
||||
resps.setErr(BizConsts.BASE_LOGIN_IS_EXPIRE_CODE, new String[]{BizConsts.BASE_LOGIN_IS_EXPIRE_MSG});
|
||||
} else if (exception instanceof LockedException) {
|
||||
resps.setErr(RespsConsts.CODE_FAIL, new String[]{BizConsts.BASE_IS_LOCKED_MSG});
|
||||
} else if (exception instanceof AuthenticationCredentialsNotFoundException) {
|
||||
resps.setErr(RespsConsts.CODE_FAIL, new String[]{BizConsts.BASE_CREDENTIALS_NOT_FOUND_MSG});
|
||||
} else if (exception instanceof ThirdPartyAuthorizationException) {
|
||||
resps.setErr(RespsConsts.CODE_FAIL, new String[]{exception.getMessage()});
|
||||
} else if (exception instanceof BadCredentialsException) {
|
||||
resps.setErr(RespsConsts.CODE_FAIL, new String[]{BizConsts.BASE_PWD_IS_ERR_MSG});
|
||||
} else if (exception instanceof UsernameNotFoundException) {
|
||||
resps.setErr(RespsConsts.CODE_FAIL, new String[]{BizConsts.BASE_ACCOUNT_NOT_FOUND_MSG});
|
||||
} else if (exception instanceof UserNotAuthoriayException) {
|
||||
resps.setErr(RespsConsts.CODE_FAIL, new String[]{exception.getMessage()});
|
||||
} else {
|
||||
resps.setErr(RespsConsts.CODE_FAIL, new String[]{BizConsts.BASE_SYS_ERR_MSG});
|
||||
}
|
||||
response.getWriter().write(JsonUtil.obj2Json(resps));
|
||||
response.getWriter().close();
|
||||
});
|
||||
```
|
||||
|
||||
2.com.yexuejc.springboot.base.security.UserDetailsManager
|
||||
<br/>
|
||||
**获取登录用户信息**
|
||||
|
24
doc/Securtity效果图.md
Normal file
@@ -0,0 +1,24 @@
|
||||
Security 多方登录封装使用效果图
|
||||
---------------
|
||||
### 账号登录
|
||||
密码错误
|
||||

|
||||
正确
|
||||

|
||||
|
||||
### 短信登录
|
||||
发送短信
|
||||

|
||||
短信错误
|
||||

|
||||
短信过期
|
||||

|
||||
正确
|
||||

|
||||
|
||||
|
||||
### 第三方登录
|
||||
第一次登录,需要绑定手机号
|
||||

|
||||
绑定过手机号的第三方账号登录(绑定相关业务需要自己实现)
|
||||

|
BIN
doc/sl/sl_01.png
Normal file
After Width: | Height: | Size: 63 KiB |
BIN
doc/sl/sl_02.png
Normal file
After Width: | Height: | Size: 46 KiB |
BIN
doc/sl/sl_10.png
Normal file
After Width: | Height: | Size: 20 KiB |
BIN
doc/sl/sl_err.jpg
Normal file
After Width: | Height: | Size: 41 KiB |
BIN
doc/sl/sl_gq.png
Normal file
After Width: | Height: | Size: 13 KiB |
BIN
doc/sl/sl_ss.png
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
doc/sl/sl_t3.png
Normal file
After Width: | Height: | Size: 70 KiB |
BIN
doc/sl/sl_t4.png
Normal file
After Width: | Height: | Size: 69 KiB |
BIN
doc/多方登录设计.jpg
Normal file
After Width: | Height: | Size: 240 KiB |