Parcourir la source

去除强登录控制

liuchengsen il y a 4 semaines
Parent
commit
dcbcda3f5a

+ 12 - 13
backend-java/src/main/java/com/pharmacopoeia/security/JwtAuthFilter.java

@@ -116,20 +116,19 @@ public class JwtAuthFilter extends OncePerRequestFilter {
         }finally {
             MDC.clear();
         }
-}
+    }
 
-private boolean isPublicPath(String uri) {
-    for (String prefix : PUBLIC_PREFIXES) {
-        if (uri.startsWith(prefix)) {
-            return true;
+    private boolean isPublicPath(String uri) {
+        for (String prefix : PUBLIC_PREFIXES) {
+            if (uri.startsWith(prefix)) {
+                return true;
+            }
         }
+        return "/".equals(uri) || uri.endsWith(".html") || uri.endsWith(".js") || uri.endsWith(".css");
+    }
+    private void send401(HttpServletResponse response, String msg) throws IOException {
+        response.setStatus(401);
+        response.setContentType("application/json;charset=UTF-8");
+        response.getWriter().write("{\"error\":\"" + msg + "\",\"code\":401}");
     }
-    return "/".equals(uri) || uri.endsWith(".html") || uri.endsWith(".js") || uri.endsWith(".css");
-}
-
-private void send401(HttpServletResponse response, String msg) throws IOException {
-    response.setStatus(401);
-    response.setContentType("application/json;charset=UTF-8");
-    response.getWriter().write("{\"error\":\"" + msg + "\",\"code\":401}");
-}
 }

+ 1 - 1
backend-java/src/main/resources/application.yml

@@ -56,7 +56,7 @@ qwen:
 # 鉴权
 # ============================================
 auth:
-  enabled: true       # 上线后改为 true
+  enabled: false       # true=上线后需要 JWT token
   admin-token: ""     # 运营端管理 token(与 JWT 无关,单独配置)
 
 # ============================================

+ 0 - 2
static/index.html

@@ -516,8 +516,6 @@
     var input=document.getElementById('userInput'),text=input.value.trim();
     var hasMedia=!!pendingMedia;
     if(!text&&!hasMedia)return;input.value='';if(STREAMING)return;
-    // 强鉴权:无 token 直接弹登录框
-    if(!TOKEN){ showLoginModal(); return; }
     track('chat', {query: text});
     doSend(text,hasMedia?pendingMedia:null);
   };