wangyunpeng 6 dni temu
rodzic
commit
913f7a5df3

+ 2 - 24
api-module/src/main/java/com/tzld/piaoquan/api/config/JwtInterceptor.java

@@ -105,8 +105,7 @@ public class JwtInterceptor implements HandlerInterceptor {
             HandlerMethod handlerMethod = (HandlerMethod) handler;
             RequireSign requireSign = handlerMethod.getMethodAnnotation(RequireSign.class);
             if (requireSign != null) {
-                // todo
-//                validateSign(request, authHeader);
+                validateSign(request, authHeader);
             }
         }
 
@@ -190,9 +189,8 @@ public class JwtInterceptor implements HandlerInterceptor {
     private void validateSign(HttpServletRequest request, String token) {
         String timestamp = request.getHeader("X-Timestamp");
         String nonce = request.getHeader("X-Nonce");
-        String sign = request.getHeader("X-Sign");
 
-        if (StringUtils.isBlank(timestamp) || StringUtils.isBlank(nonce) || StringUtils.isBlank(sign)) {
+        if (StringUtils.isBlank(timestamp) || StringUtils.isBlank(nonce)) {
             throw new CommonException(ExceptionEnum.PARAM_ERROR.getCode(), "请求缺少签名参数");
         }
 
@@ -216,26 +214,6 @@ public class JwtInterceptor implements HandlerInterceptor {
             throw new CommonException(ExceptionEnum.PARAM_ERROR.getCode(), "请求不能重复提交");
         }
 
-        // 获取 signKey
-        String signKey = redisUtils.getString("sign_key." + token);
-        if (StringUtils.isBlank(signKey)) {
-            throw new CommonException(ExceptionEnum.Not_LOGIN);
-        }
-
-        // 读取 request body
-        String body = getRequestBody(request);
-
-        // 计算预期签名
-        String method = request.getMethod();
-        String uri = request.getServletPath();
-        String payload = method + ":" + uri + ":" + timestamp + ":" + nonce + ":" + body;
-        String expectedSign = hmacSha256(payload, signKey);
-
-        if (!MessageDigest.isEqual(expectedSign.getBytes(StandardCharsets.UTF_8),
-                sign.getBytes(StandardCharsets.UTF_8))) {
-            log.warn("Sign mismatch - uri={}, expected={}, actual={}", uri, expectedSign, sign);
-            throw new CommonException(ExceptionEnum.PARAM_ERROR.getCode(), "签名校验失败");
-        }
     }
 
     private String getRequestBody(HttpServletRequest request) {

+ 0 - 2
api-module/src/main/java/com/tzld/piaoquan/api/controller/contentplatform/LoghubController.java

@@ -1,7 +1,6 @@
 package com.tzld.piaoquan.api.controller.contentplatform;
 
 
-import com.tzld.piaoquan.api.annotation.RequireSign;
 import com.tzld.piaoquan.api.model.param.contentplatform.LogUploadParam;
 import com.tzld.piaoquan.api.service.LoghubService;
 import com.tzld.piaoquan.growth.common.common.base.CommonResponse;
@@ -17,7 +16,6 @@ public class LoghubController {
     LoghubService loghubService;
 
     @PostMapping("/upload")
-    @RequireSign
     public CommonResponse<Void> logUpload(@RequestBody LogUploadParam param) {
         loghubService.logUploadByKey(param.getData(), param.getKey());
         return CommonResponse.success();