From a6157389dc4ba0098e13cbcd41b2533bf7cab0ef Mon Sep 17 00:00:00 2001 From: shaohuzhang1 Date: Tue, 11 Aug 2026 15:31:49 +0800 Subject: [PATCH] fix: OpenAI dialogue compatibility interface authentication --- apps/common/auth/authenticate.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/common/auth/authenticate.py b/apps/common/auth/authenticate.py index c931c70d42b..d2b369e2798 100644 --- a/apps/common/auth/authenticate.py +++ b/apps/common/auth/authenticate.py @@ -54,6 +54,11 @@ def get_token_details(self): return self.token_details +agent_handle = [new_instance_by_class_path(class_path) for class_path in settings.AGENT_HANDLES] + +all_handles = handles + agent_handle + + class OpenAIKeyAuth(TokenAuthentication): def authenticate(self, request): auth = request.META.get('HTTP_AUTHORIZATION') @@ -63,7 +68,7 @@ def authenticate(self, request): raise AppAuthenticationFailed(1003, _('Not logged in, please log in first')) try: token_details = TokenDetails(auth) - for handle in handles: + for handle in all_handles: 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')) @@ -96,10 +101,6 @@ def authenticate(self, request): raise AppAuthenticationFailed(1002, _('Authentication information is incorrect! illegal user')) -agent_handle = [new_instance_by_class_path(class_path) for class_path in settings.AGENT_HANDLES] - -all_handles = handles + agent_handle - class AgentTokenAuth(TokenAuthentication): keyword = "Bearer" @@ -144,4 +145,3 @@ def authenticate(self, request): AppApiException): raise e raise AppAuthenticationFailed(1002, _('Authentication information is incorrect! illegal user')) -