Browse Source

鉴权暂时去掉

wangliang 4 years ago
parent
commit
848bee3b8c

+ 33 - 33
themis-business/src/main/java/com/qmth/themis/business/util/AuthUtil.java

@@ -127,45 +127,45 @@ public class AuthUtil {
                                     String method,
                                     String url) {
         RedisUtil redisUtil = SpringContextHolder.getBean(RedisUtil.class);
-        if (SystemConstant.expire(time)) {
-            log.warn("Authorization faile: time expired, server time=" + System.currentTimeMillis());
-            throw new BusinessException(ExceptionResultEnum.AUTHORIZATION_ERROR);
-        }
+//        if (SystemConstant.expire(time)) {
+//            log.warn("Authorization faile: time expired, server time=" + System.currentTimeMillis());
+//            throw new BusinessException(ExceptionResultEnum.AUTHORIZATION_ERROR);
+//        }
         //测试
 //        final SignatureInfo info = SignatureInfo.parse(authorization);
         //校验签名信息
         final SignatureInfo info = SignatureInfo.parse(method.toLowerCase(), url, time, authorization);
-        if (info == null) {
-            log.warn("Authorization faile: signature decode error");
-            throw new BusinessException(ExceptionResultEnum.AUTHORIZATION_ERROR);
-        }
-        if (SignatureType.TOKEN != info.getType()) {
-            log.warn("Authorization faile: signature type is not Token");
-            throw new BusinessException(ExceptionResultEnum.AUTHORIZATION_ERROR);
-        }
-        //校验session
+//        if (info == null) {
+//            log.warn("Authorization faile: signature decode error");
+//            throw new BusinessException(ExceptionResultEnum.AUTHORIZATION_ERROR);
+//        }
+//        if (SignatureType.TOKEN != info.getType()) {
+//            log.warn("Authorization faile: signature type is not Token");
+//            throw new BusinessException(ExceptionResultEnum.AUTHORIZATION_ERROR);
+//        }
+//        //校验session
         String sessionId = info.getInvoker();
         TBSession tbSession = (TBSession) redisUtil.getUserSession(sessionId);
-        if (Objects.isNull(tbSession)) {
-            log.warn("Authorization faile: session id not exists: " + sessionId);
-            throw new BusinessException(ExceptionResultEnum.LOGIN_NO);
-        }
-        if (tbSession.getExpireTime() <= System.currentTimeMillis() || info.getTimestamp() > tbSession.getExpireTime()) {
-            log.warn("Authorization faile: session has expired, expire time=" + tbSession.getExpireTime());
-            throw new BusinessException(ExceptionResultEnum.LOGIN_NO);
-        }
-        if (!info.validate(tbSession.getAccessToken())) {
-            log.warn("Authorization faile: access token invalid, session token is " + tbSession.getAccessToken());
-            throw new BusinessException(ExceptionResultEnum.AUTHORIZATION_ERROR);
-        }
-        if (!tbSession.getPlatform().equalsIgnoreCase(platform.name())) {
-            log.warn("Authorization faile: platform invalid, session platform is " + tbSession.getPlatform());
-            throw new BusinessException(ExceptionResultEnum.AUTHORIZATION_ERROR);
-        }
-        if (!tbSession.getDeviceId().equalsIgnoreCase(deviceId)) {
-            log.warn("Authorization faile: deviceId invalid, session deviceId is " + tbSession.getDeviceId());
-            throw new BusinessException(ExceptionResultEnum.AUTHORIZATION_ERROR);
-        }
+//        if (Objects.isNull(tbSession)) {
+//            log.warn("Authorization faile: session id not exists: " + sessionId);
+//            throw new BusinessException(ExceptionResultEnum.LOGIN_NO);
+//        }
+//        if (tbSession.getExpireTime() <= System.currentTimeMillis() || info.getTimestamp() > tbSession.getExpireTime()) {
+//            log.warn("Authorization faile: session has expired, expire time=" + tbSession.getExpireTime());
+//            throw new BusinessException(ExceptionResultEnum.LOGIN_NO);
+//        }
+//        if (!info.validate(tbSession.getAccessToken())) {
+//            log.warn("Authorization faile: access token invalid, session token is " + tbSession.getAccessToken());
+//            throw new BusinessException(ExceptionResultEnum.AUTHORIZATION_ERROR);
+//        }
+//        if (!tbSession.getPlatform().equalsIgnoreCase(platform.name())) {
+//            log.warn("Authorization faile: platform invalid, session platform is " + tbSession.getPlatform());
+//            throw new BusinessException(ExceptionResultEnum.AUTHORIZATION_ERROR);
+//        }
+//        if (!tbSession.getDeviceId().equalsIgnoreCase(deviceId)) {
+//            log.warn("Authorization faile: deviceId invalid, session deviceId is " + tbSession.getDeviceId());
+//            throw new BusinessException(ExceptionResultEnum.AUTHORIZATION_ERROR);
+//        }
         return tbSession;
     }