Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions apps/common/auth/authenticate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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'))
Expand Down Expand Up @@ -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"

Expand Down Expand Up @@ -144,4 +145,3 @@ def authenticate(self, request):
AppApiException):
raise e
raise AppAuthenticationFailed(1002, _('Authentication information is incorrect! illegal user'))

Loading