fix: 修复对话框秘钥校验无法弹出 (#1431)
This commit is contained in:
parent
23c7269231
commit
0440d68bf2
@ -14,7 +14,8 @@ from django.core import cache
|
|||||||
from django.core import signing
|
from django.core import signing
|
||||||
from rest_framework.authentication import TokenAuthentication
|
from rest_framework.authentication import TokenAuthentication
|
||||||
|
|
||||||
from common.exception.app_exception import AppAuthenticationFailed, AppEmbedIdentityFailed, AppChatNumOutOfBoundsFailed
|
from common.exception.app_exception import AppAuthenticationFailed, AppEmbedIdentityFailed, AppChatNumOutOfBoundsFailed, \
|
||||||
|
ChatException, AppApiException
|
||||||
|
|
||||||
token_cache = cache.caches['token_cache']
|
token_cache = cache.caches['token_cache']
|
||||||
|
|
||||||
@ -67,7 +68,8 @@ class OpenAIKeyAuth(TokenAuthentication):
|
|||||||
raise AppAuthenticationFailed(1002, "身份验证信息不正确!非法用户")
|
raise AppAuthenticationFailed(1002, "身份验证信息不正确!非法用户")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
traceback.format_exc()
|
traceback.format_exc()
|
||||||
if isinstance(e, AppEmbedIdentityFailed) or isinstance(e, AppChatNumOutOfBoundsFailed):
|
if isinstance(e, AppEmbedIdentityFailed) or isinstance(e, AppChatNumOutOfBoundsFailed) or isinstance(e,
|
||||||
|
AppApiException):
|
||||||
raise e
|
raise e
|
||||||
raise AppAuthenticationFailed(1002, "身份验证信息不正确!非法用户")
|
raise AppAuthenticationFailed(1002, "身份验证信息不正确!非法用户")
|
||||||
|
|
||||||
@ -87,6 +89,7 @@ class TokenAuth(TokenAuthentication):
|
|||||||
raise AppAuthenticationFailed(1002, "身份验证信息不正确!非法用户")
|
raise AppAuthenticationFailed(1002, "身份验证信息不正确!非法用户")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
traceback.format_exc()
|
traceback.format_exc()
|
||||||
if isinstance(e, AppEmbedIdentityFailed) or isinstance(e, AppChatNumOutOfBoundsFailed):
|
if isinstance(e, AppEmbedIdentityFailed) or isinstance(e, AppChatNumOutOfBoundsFailed) or isinstance(e,
|
||||||
|
AppApiException):
|
||||||
raise e
|
raise e
|
||||||
raise AppAuthenticationFailed(1002, "身份验证信息不正确!非法用户")
|
raise AppAuthenticationFailed(1002, "身份验证信息不正确!非法用户")
|
||||||
|
|||||||
@ -31,20 +31,21 @@ class PublicAccessToken(AuthBaseHandle):
|
|||||||
auth_details = get_token_details()
|
auth_details = get_token_details()
|
||||||
application_access_token = QuerySet(ApplicationAccessToken).filter(
|
application_access_token = QuerySet(ApplicationAccessToken).filter(
|
||||||
application_id=auth_details.get('application_id')).first()
|
application_id=auth_details.get('application_id')).first()
|
||||||
application_setting_model = DBModelManage.get_model('application_setting')
|
if request.path != '/api/application/profile':
|
||||||
xpack_cache = DBModelManage.get_model('xpack_cache')
|
application_setting_model = DBModelManage.get_model('application_setting')
|
||||||
X_PACK_LICENSE_IS_VALID = False if xpack_cache is None else xpack_cache.get('XPACK_LICENSE_IS_VALID', False)
|
xpack_cache = DBModelManage.get_model('xpack_cache')
|
||||||
if application_setting_model is not None and X_PACK_LICENSE_IS_VALID:
|
X_PACK_LICENSE_IS_VALID = False if xpack_cache is None else xpack_cache.get('XPACK_LICENSE_IS_VALID', False)
|
||||||
application_setting = QuerySet(application_setting_model).filter(application_id=str(
|
if application_setting_model is not None and X_PACK_LICENSE_IS_VALID:
|
||||||
application_access_token.application_id)).first()
|
application_setting = QuerySet(application_setting_model).filter(application_id=str(
|
||||||
if application_setting.authentication:
|
application_access_token.application_id)).first()
|
||||||
authentication = auth_details.get('authentication', {})
|
if application_setting.authentication:
|
||||||
if authentication is None:
|
authentication = auth_details.get('authentication', {})
|
||||||
authentication = {}
|
if authentication is None:
|
||||||
if application_setting.authentication_value.get('type') != authentication.get(
|
authentication = {}
|
||||||
'type') or password_encrypt(
|
if application_setting.authentication_value.get('type') != authentication.get(
|
||||||
application_setting.authentication_value.get('value')) != authentication.get('value'):
|
'type') or password_encrypt(
|
||||||
raise ChatException(1002, "身份验证信息不正确")
|
application_setting.authentication_value.get('value')) != authentication.get('value'):
|
||||||
|
raise ChatException(1002, "身份验证信息不正确")
|
||||||
if application_access_token is None:
|
if application_access_token is None:
|
||||||
raise AppAuthenticationFailed(1002, "身份验证信息不正确")
|
raise AppAuthenticationFailed(1002, "身份验证信息不正确")
|
||||||
if not application_access_token.is_active:
|
if not application_access_token.is_active:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user