From bec58fa7fe4fae2deac88200d8d939e12ec8a08f Mon Sep 17 00:00:00 2001
From: lrj <owen.stl@gmail.com>
Date: 星期五, 03 十月 2025 22:26:39 +0800
Subject: [PATCH] 修复小程序WXS日期显示问题并重新设计【我的】页面
---
backend/src/main/java/com/rongyichuang/auth/filter/JwtAuthenticationFilter.java | 44 ++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 42 insertions(+), 2 deletions(-)
diff --git a/backend/src/main/java/com/rongyichuang/auth/filter/JwtAuthenticationFilter.java b/backend/src/main/java/com/rongyichuang/auth/filter/JwtAuthenticationFilter.java
index 4fef1a3..96e6413 100644
--- a/backend/src/main/java/com/rongyichuang/auth/filter/JwtAuthenticationFilter.java
+++ b/backend/src/main/java/com/rongyichuang/auth/filter/JwtAuthenticationFilter.java
@@ -36,12 +36,52 @@
@Autowired
private UserRepository userRepository;
+
+ /**
+ * 鍒ゆ柇鏄惁搴旇璺宠繃JWT璁よ瘉
+ */
+ private boolean shouldSkipAuthentication(String requestURI) {
+ // 杩欎簺璺緞涓嶉渶瑕丣WT璁よ瘉锛堝凡鍘绘帀context path锛�
+ String[] skipPaths = {
+ "/auth/",
+ "/actuator/",
+ "/test/",
+ "/cleanup/",
+ "/upload/",
+ "/graphql",
+ "/graphiql"
+ };
+
+ for (String path : skipPaths) {
+ if (requestURI.startsWith(path)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response,
FilterChain filterChain) throws ServletException, IOException {
- System.out.println("=== JWT杩囨护鍣ㄨ璋冪敤 === URI: " + request.getRequestURI());
- logger.debug("JWT杩囨护鍣ㄥ紑濮嬪鐞嗚姹�: {}", request.getRequestURI());
+ String requestURI = request.getRequestURI();
+ String contextPath = request.getContextPath();
+
+ // 鍘绘帀context path锛屼笌Spring Security鐨勮涓轰繚鎸佷竴鑷�
+ String pathWithoutContext = requestURI;
+ if (contextPath != null && !contextPath.isEmpty() && requestURI.startsWith(contextPath)) {
+ pathWithoutContext = requestURI.substring(contextPath.length());
+ }
+
+ System.out.println("=== JWT杩囨护鍣ㄨ璋冪敤 === 鍘熷URI: " + requestURI + ", 鍘绘帀context path鍚�: " + pathWithoutContext);
+ logger.debug("JWT杩囨护鍣ㄥ紑濮嬪鐞嗚姹�: {}", pathWithoutContext);
+
+ // 璺宠繃涓嶉渶瑕佽璇佺殑璺緞
+ if (shouldSkipAuthentication(pathWithoutContext)) {
+ logger.debug("璺宠繃JWT璁よ瘉锛岃矾寰�: {}", pathWithoutContext);
+ filterChain.doFilter(request, response);
+ return;
+ }
String authHeader = request.getHeader("Authorization");
String token = null;
--
Gitblit v1.8.0