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
6 changes: 5 additions & 1 deletion apps/common/auth/handle/impl/application_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
class ApplicationKey(AuthBaseHandle):
def handle(self, request, token: str, get_token_details):
application_api_key = QuerySet(ApplicationApiKey).filter(secret_key=token).first()
QuerySet()
if application_api_key is None:
raise AppAuthenticationFailed(500, _("Secret key is invalid"))
if not application_api_key.is_active:
Expand All @@ -31,10 +32,13 @@ def handle(self, request, token: str, get_token_details):
QuerySet(ApplicationAccessToken).filter(application_id=application_api_key.application_id).first()
)
if application_access_token is not None:
if not application_access_token.enable_api_key:
raise AppAuthenticationFailed(1002, _("Authentication information is incorrect"))
if application_access_token.authentication:
if application_access_token.authentication_value.get("type", "password") != "password":
raise AppAuthenticationFailed(1002, _("Authentication information is incorrect"))

else:
raise AppAuthenticationFailed(1002, _("Authentication information is incorrect"))
k = f"{Group.CHAT_USER}:r:{application_access_token.application_id}"
return Principal(
str(application_api_key.id),
Expand Down
Loading