|
|
@@ -32,6 +32,9 @@ public class AuthHandlerAspectJ {
|
|
|
@Value("${jwt.secret}")
|
|
|
private String jwtSecret;
|
|
|
|
|
|
+ @Value("${jwt.sys-secret}")
|
|
|
+ private String jwtSysSecret;
|
|
|
+
|
|
|
@Before("execution(public * cn.seecoder.data.server.controller.*.*(..)) && @annotation(auth)")
|
|
|
public void authCheck(JoinPoint joinPoint, Auth auth) {
|
|
|
HttpServletRequest httpServletRequest =
|
|
|
@@ -40,10 +43,25 @@ public class AuthHandlerAspectJ {
|
|
|
String token = Optional.ofNullable(httpServletRequest.getHeader("Authorization"))
|
|
|
.orElseThrow(() -> new GlobalException(ErrorCodeEnum.USER_ERROR_A0001));
|
|
|
|
|
|
+
|
|
|
+
|
|
|
JWTVerifier jwtVerifier = JWT.require(Algorithm.HMAC256(jwtSecret)).build();
|
|
|
+ JWTVerifier jwtVerifierSys = JWT.require(Algorithm.HMAC256(jwtSysSecret)).build();
|
|
|
|
|
|
DecodedJWT decodedJWT;
|
|
|
|
|
|
+
|
|
|
+ // token = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJza3kiOiJXb0JpU2hlWWFvWGllQnVXYW5MZSEhIn0.QDF9l3beb2vodPMH87adsT4DZL60NU6Zf4uYAxelzg8
|
|
|
+ for(UserRole role : auth.roles()) {
|
|
|
+ if(role == UserRole.SYS) {
|
|
|
+ try {
|
|
|
+ decodedJWT = jwtVerifierSys.verify(token);
|
|
|
+ String decodedString = decodedJWT.getClaim("sky").asString();
|
|
|
+ if (decodedString.equals("WoBiSheYaoXieBuWanLe!!")) return;
|
|
|
+ } catch (JWTVerificationException ignored) {}
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
try {
|
|
|
decodedJWT = jwtVerifier.verify(token);
|
|
|
} catch (JWTVerificationException e) {
|