mirror of https://github.com/jumpserver/jumpserver
perf: 取消API Token的配置
parent
773f7048be
commit
1a1ad0f1a2
|
@ -298,28 +298,33 @@ class IndexApi(DatesLoginMetricMixin, APIView):
|
||||||
|
|
||||||
|
|
||||||
class HealthApiMixin(APIView):
|
class HealthApiMixin(APIView):
|
||||||
def is_token_right(self):
|
pass
|
||||||
token = self.request.query_params.get('token')
|
|
||||||
ok_token = settings.HEALTH_CHECK_TOKEN
|
|
||||||
if ok_token and token != ok_token:
|
|
||||||
return False
|
|
||||||
return True
|
|
||||||
|
|
||||||
def is_localhost(self):
|
# 先去掉 Health Api 的权限校验,方便各组件直接调用
|
||||||
ip = get_request_ip(self.request)
|
|
||||||
return ip in ['localhost', '127.0.0.1']
|
|
||||||
|
|
||||||
def check_permissions(self, request):
|
# def is_token_right(self):
|
||||||
if self.is_token_right():
|
# token = self.request.query_params.get('token')
|
||||||
return
|
# ok_token = settings.HEALTH_CHECK_TOKEN
|
||||||
if self.is_localhost():
|
# if ok_token and token != ok_token:
|
||||||
return
|
# return False
|
||||||
msg = '''
|
# return True
|
||||||
Health check token error,
|
|
||||||
Please set query param in url and same with setting HEALTH_CHECK_TOKEN.
|
# def is_localhost(self):
|
||||||
eg: $PATH/?token=$HEALTH_CHECK_TOKEN
|
# ip = get_request_ip(self.request)
|
||||||
'''
|
# return ip in ['localhost', '127.0.0.1']
|
||||||
self.permission_denied(request, message={'error': msg}, code=403)
|
|
||||||
|
# def check_permissions(self, request):
|
||||||
|
# if self.is_token_right():
|
||||||
|
# return
|
||||||
|
# if self.is_localhost():
|
||||||
|
# return
|
||||||
|
# msg = '''
|
||||||
|
# Health check token error,
|
||||||
|
# Please set query param in url and
|
||||||
|
# same with setting HEALTH_CHECK_TOKEN.
|
||||||
|
# eg: $PATH/?token=$HEALTH_CHECK_TOKEN
|
||||||
|
# '''
|
||||||
|
# self.permission_denied(request, message={'error': msg}, code=403)
|
||||||
|
|
||||||
|
|
||||||
class HealthCheckView(HealthApiMixin):
|
class HealthCheckView(HealthApiMixin):
|
||||||
|
|
|
@ -17,9 +17,9 @@ class AuthSettingSerializer(serializers.Serializer):
|
||||||
FORGOT_PASSWORD_URL = serializers.CharField(
|
FORGOT_PASSWORD_URL = serializers.CharField(
|
||||||
required=False, max_length=1024, label=_("Forgot password url")
|
required=False, max_length=1024, label=_("Forgot password url")
|
||||||
)
|
)
|
||||||
HEALTH_CHECK_TOKEN = serializers.CharField(
|
# HEALTH_CHECK_TOKEN = serializers.CharField(
|
||||||
required=False, max_length=1024, label=_("Health check token")
|
# required=False, max_length=1024, label=_("Health check token")
|
||||||
)
|
# )
|
||||||
LOGIN_REDIRECT_MSG_ENABLED = serializers.BooleanField(
|
LOGIN_REDIRECT_MSG_ENABLED = serializers.BooleanField(
|
||||||
required=False, label=_("Enable login redirect msg")
|
required=False, label=_("Enable login redirect msg")
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue