feat: Modify the dialogue apikey generation rules (#4582)

This commit is contained in:
shaohuzhang1 2025-12-30 10:43:47 +08:00 committed by GitHub
parent 83a328df8e
commit 9586c1b6de
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 2 deletions

View File

@ -47,7 +47,7 @@ class ApplicationKeySerializer(serializers.Serializer):
self.is_valid(raise_exception=True)
application_id = self.data.get("application_id")
application = QuerySet(Application).filter(id=application_id).first()
secret_key = 'application-' + hashlib.md5(str(uuid.uuid7()).encode()).hexdigest()
secret_key = 'agent-' + hashlib.md5(str(uuid.uuid7()).encode()).hexdigest()
application_api_key = ApplicationApiKey(id=uuid.uuid7(),
secret_key=secret_key,
user_id=application.user_id,

View File

@ -39,4 +39,4 @@ class ApplicationKey(AuthBaseHandle):
chat_user_type=ChatUserType.ANONYMOUS_USER.value)
def support(self, request, token: str, get_token_details):
return str(token).startswith("application-")
return str(token).startswith("application-") or str(token).startswith('agent-')