Browse Source

对oidc用户进程校验

tags/V1.3.3^2
wanjing 1 year ago
parent
commit
e8de1fab0f
2 changed files with 22 additions and 0 deletions
  1. +5
    -0
      tuoheng-common/tuoheng-common-core/src/main/java/com/tuoheng/common/core/utils/JsonResult.java
  2. +17
    -0
      tuoheng-common/tuoheng-common-core/src/main/java/com/tuoheng/common/core/utils/SecurityUserUtils.java

+ 5
- 0
tuoheng-common/tuoheng-common-core/src/main/java/com/tuoheng/common/core/utils/JsonResult.java View File

@@ -22,6 +22,11 @@ public class JsonResult<T> implements Serializable {
*/
public static final int ERROR = -1;

/**
* 专用
*/
public static final int OIDC_ERROR = -2;

private int code;

private String msg;

+ 17
- 0
tuoheng-common/tuoheng-common-core/src/main/java/com/tuoheng/common/core/utils/SecurityUserUtils.java View File

@@ -42,6 +42,7 @@ public class SecurityUserUtils {
}

public static String token() {
check();
// header中获取用户token
String token = ServletUtils.getRequest().getHeader("th-token");
if (StringUtils.isEmpty(token)) {
@@ -56,6 +57,7 @@ public class SecurityUserUtils {
* @return
*/
public static String username() {
check();
// header中获取用户token
String oUserJson = ServletUtils.getRequest().getHeader("o-user-json");
if (StringUtils.isEmpty(oUserJson)) {
@@ -67,4 +69,19 @@ public class SecurityUserUtils {
return username;
}

public static void check() {
String oUserJson = ServletUtils.getRequest().getHeader("o-user-json");
String json = EncryptUtil.decodeUTF8StringBase64(oUserJson);
JSONObject jsonObject = JSON.parseObject(json);
Integer isAble = jsonObject.getInteger("isAble");
Integer isExpire = jsonObject.getInteger("isExpire");
if (StringUtils.isNotNull(isAble) && StringUtils.isNotNull(isExpire)) {
if (0 == isAble) {
throw new ServiceException(JsonResult.OIDC_ERROR, "该账号已被禁用,请联系系统管理员");
}
if (0 == isExpire) {
throw new ServiceException(JsonResult.OIDC_ERROR, "系统有效期已过,请联系系统管理员");
}
}
}
}

Loading…
Cancel
Save