|
@@ -1,5 +1,6 @@
|
|
|
package cn.reghao.tnb.account.app.util;
|
|
package cn.reghao.tnb.account.app.util;
|
|
|
|
|
|
|
|
|
|
+import cn.reghao.jutil.jdk.string.IDObfuscation;
|
|
|
import cn.reghao.tnb.account.app.model.vo.RefreshPayload;
|
|
import cn.reghao.tnb.account.app.model.vo.RefreshPayload;
|
|
|
import cn.reghao.tnb.account.app.security.form.AccountAuthToken;
|
|
import cn.reghao.tnb.account.app.security.form.AccountAuthToken;
|
|
|
import io.jsonwebtoken.Claims;
|
|
import io.jsonwebtoken.Claims;
|
|
@@ -97,21 +98,22 @@ public class JwtUtil {
|
|
|
return new AccountAuthToken(plat, loginId, loginType, userId, authorities);
|
|
return new AccountAuthToken(plat, loginId, loginType, userId, authorities);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public static AccountAuthToken getAuthentication1(String token, RSAPublicKey signKey) {
|
|
|
|
|
|
|
+ public static AccountAuthToken getAuthentication1(String token, RSAPublicKey signKey, IDObfuscation userIdObfuscation) {
|
|
|
Claims claims = Jwts.parser().setSigningKey(signKey).parseClaimsJws(token).getBody();
|
|
Claims claims = Jwts.parser().setSigningKey(signKey).parseClaimsJws(token).getBody();
|
|
|
Integer plat = (Integer) claims.get("plat");
|
|
Integer plat = (Integer) claims.get("plat");
|
|
|
String loginId = (String) claims.get("loginId");
|
|
String loginId = (String) claims.get("loginId");
|
|
|
int loginType = (int) claims.get("loginType");
|
|
int loginType = (int) claims.get("loginType");
|
|
|
- String userId = claims.getSubject();
|
|
|
|
|
|
|
+ String userIdStr = claims.getSubject();
|
|
|
// TODO userId 是系统分配且固定的,但需要检查用户的 roles 是否发生变化
|
|
// TODO userId 是系统分配且固定的,但需要检查用户的 roles 是否发生变化
|
|
|
String roles = (String) claims.get("authorities");
|
|
String roles = (String) claims.get("authorities");
|
|
|
long expireAt = claims.getExpiration().getTime();
|
|
long expireAt = claims.getExpiration().getTime();
|
|
|
- if (plat == null || loginId == null || userId == null || roles == null) {
|
|
|
|
|
|
|
+ if (plat == null || loginId == null || userIdStr == null || roles == null) {
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
List<GrantedAuthority> authorities = AuthorityUtils.commaSeparatedStringToAuthorityList(roles);
|
|
List<GrantedAuthority> authorities = AuthorityUtils.commaSeparatedStringToAuthorityList(roles);
|
|
|
- return new AccountAuthToken(plat, loginId, loginType, userId, authorities);
|
|
|
|
|
|
|
+ long userId = userIdObfuscation.restore(userIdStr);
|
|
|
|
|
+ return new AccountAuthToken(plat, loginId, loginType, userId+"", authorities);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|