Ver código fonte

[Feature] Message Send Interface: bugfix

AA 11 meses atrás
pai
commit
82e2792575

+ 3 - 12
src/main/java/com/dragon/tj/portal/auth/config/WebSecurityConfig.java

@@ -95,28 +95,19 @@ public class WebSecurityConfig {
                 .csrf(CsrfConfigurer::disable)
                 .authorizeRequests(authorizeRequests -> authorizeRequests.anyRequest().authenticated())
                 .sessionManagement(sessionManagement -> sessionManagement.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
-                .exceptionHandling(exceptions -> exceptions.authenticationEntryPoint(globalAuthenticationEntryPoint()))
+                // hmacFilter情况下大概率用不到这个exceptionHandling
+                .exceptionHandling(exceptions -> exceptions.authenticationEntryPoint(apiAuthenticationEntryPoint()))
                 // 内置filters已经排序 FilterOrderRegistration.FilterOrderRegistration()
                 .addFilterBefore(hmacAuthenticationFilter(), UsernamePasswordAuthenticationFilter.class);
         return http.build();
     }
 
-    // TODO: 2024/7/17 sai Delete
-    public AuthenticationEntryPoint globalAuthenticationEntryPoint() {
-        return (request, response, authException) -> {
-            response.setStatus(HttpStatus.UNAUTHORIZED.value());
-            response.setCharacterEncoding(StandardCharsets.UTF_8.name());
-            response.setContentType(MediaType.APPLICATION_JSON.toString());
-            response.getWriter().write("{\"message:\":\"Global认证失败:" + authException.getMessage() + "\"}");
-        };
-    }
-
     public AuthenticationEntryPoint apiAuthenticationEntryPoint() {
         return (request, response, authException) -> {
             response.setStatus(HttpStatus.UNAUTHORIZED.value());
             response.setCharacterEncoding(StandardCharsets.UTF_8.name());
             response.setContentType(MediaType.APPLICATION_JSON.toString());
-            response.getWriter().write("{\"message:\":\"认证失败:" + authException.getMessage() + "\"}");
+            response.getWriter().write("{\"msg:\":\"认证失败:" + authException.getMessage() + "\"}");
         };
     }
 

+ 2 - 3
src/main/java/com/dragon/tj/portal/auth/module/hmac/HmacAuthenticationFilter.java

@@ -41,8 +41,7 @@ public class HmacAuthenticationFilter extends AbstractAuthenticationProcessingFi
         }
         // 大于5分钟,非法请求
         long diff = System.currentTimeMillis() - Long.parseLong(timestamp);
-        // TODO: 2024/7/17 sai default timeout 5m
-        if (Math.abs(diff) > 1000 * 60 * 500) {
+        if (Math.abs(diff) > 1000 * 60 * 5) {
             throw new BadCredentialsException("请求超时");
         }
         // 随机字符串,防止重复提交
@@ -72,7 +71,7 @@ public class HmacAuthenticationFilter extends AbstractAuthenticationProcessingFi
         if (!signature.equals(signResult)) {
             throw new BadCredentialsException("Signature验证错误");
         }
-        // TODO: 2024/7/17 sai
+        // TODO: 2024/7/17 sai nonce重复请求校验
 
         // authorities参数必填使authenticated为true
         return new UsernamePasswordAuthenticationToken(appKey, signature, null);

+ 0 - 3
src/main/java/com/dragon/tj/portal/common/dto/message/MessageInfoItem.java

@@ -35,9 +35,6 @@ public class MessageInfoItem {
      *
      *--------------非req参数
      */
-    /**
-     * TODO appId
-     */
     private String appId = "appId";
 
     /**

+ 0 - 3
src/main/java/com/dragon/tj/portal/common/dto/message/MessageInfoReq.java

@@ -67,9 +67,6 @@ public class MessageInfoReq {
      *
      *--------------非req参数
      */
-    /**
-     * TODO appId
-     */
     private String appId = "appId";
 
     /**

+ 0 - 3
src/main/java/com/dragon/tj/portal/common/dto/notice/NoticeInfoItem.java

@@ -52,9 +52,6 @@ public class NoticeInfoItem {
      *
      *--------------非req参数
      */
-    /**
-     * TODO appId
-     */
     private String appId = "appId";
 
     /**

+ 0 - 1
src/main/java/com/dragon/tj/portal/service/impl/MessageInfoServiceImpl.java

@@ -268,7 +268,6 @@ public class MessageInfoServiceImpl extends ServiceImpl<MessageInfoMapper, Messa
      * @Date Created in 2023/6/16 11:25
      */
     private boolean doMessage(MessageInfoReq messageInfoReq, LoginUser loginUser) {
-
         if (this.validate(messageInfoReq, loginUser.getIdCard())) {
             return this.transferIds(messageInfoReq, loginUser);
         }