From 996ff48be2f6ee70bf3337d9b8060856739bdbb4 Mon Sep 17 00:00:00 2001 From: wxg0103 <727495428@qq.com> Date: Mon, 10 Aug 2026 14:09:21 +0800 Subject: [PATCH] fix: simplify authentication token handling by removing Bearer prefix check --- apps/common/auth/authenticate.py | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/apps/common/auth/authenticate.py b/apps/common/auth/authenticate.py index 4deaddb5663..c931c70d42b 100644 --- a/apps/common/auth/authenticate.py +++ b/apps/common/auth/authenticate.py @@ -109,14 +109,11 @@ def authenticate(self, request): # 未认证 if auth is None: raise AppAuthenticationFailed(1003, _('Not logged in, please log in first')) - if not auth.startswith("Bearer "): - raise AppAuthenticationFailed(1002, _('Authentication information is incorrect! illegal user')) try: - token = auth[7:] - token_details = TokenDetails(token) + token_details = TokenDetails(auth) for handle in agent_handle: - if handle.support(request, token, token_details.get_token_details): - return handle.handle(request, token, token_details.get_token_details) + if handle.support(request, auth, token_details.get_token_details): + return handle.handle(request, auth, token_details.get_token_details) raise AppAuthenticationFailed(1002, _('Authentication information is incorrect! illegal user')) except Exception as e: traceback.format_exc() @@ -135,14 +132,11 @@ def authenticate(self, request): # 未认证 if auth is None: raise AppAuthenticationFailed(1003, _('Not logged in, please log in first')) - if not auth.startswith("Bearer "): - raise AppAuthenticationFailed(1002, _('Authentication information is incorrect! illegal user')) try: - token = auth[7:] - token_details = TokenDetails(token) + token_details = TokenDetails(auth) for handle in all_handles: - if handle.support(request, token, token_details.get_token_details): - return handle.handle(request, token, token_details.get_token_details) + if handle.support(request, auth, token_details.get_token_details): + return handle.handle(request, auth, token_details.get_token_details) raise AppAuthenticationFailed(1002, _('Authentication information is incorrect! illegal user')) except Exception as e: traceback.format_exc()