From 185f33c3e01b77af736eeaa8bb8a035abf437be9 Mon Sep 17 00:00:00 2001 From: jiangweidong Date: Mon, 8 May 2023 16:55:04 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=81=E4=B8=9A=E5=BE=AE=E4=BF=A1?= =?UTF-8?q?=E3=80=81=E9=92=89=E9=92=89=E3=80=81=E9=A3=9E=E4=B9=A6=E6=9C=AC?= =?UTF-8?q?=E5=9C=B0=E6=B2=A1=E6=9C=89=E7=94=A8=E6=88=B7=E5=8D=B3=E5=88=9B?= =?UTF-8?q?=E5=BB=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/authentication/views/base.py | 7 ------- apps/authentication/views/dingtalk.py | 2 -- apps/authentication/views/feishu.py | 2 -- apps/authentication/views/wecom.py | 2 -- apps/jumpserver/conf.py | 3 --- apps/settings/serializers/auth/dingtalk.py | 3 --- apps/settings/serializers/auth/feishu.py | 3 --- apps/settings/serializers/auth/wecom.py | 3 --- 8 files changed, 25 deletions(-) diff --git a/apps/authentication/views/base.py b/apps/authentication/views/base.py index 825c37619..e98e41e70 100644 --- a/apps/authentication/views/base.py +++ b/apps/authentication/views/base.py @@ -25,11 +25,9 @@ class BaseLoginCallbackView(AuthMixin, FlashMessageMixin, View): client_auth_params = {} user_type = '' auth_backend = None - create_user_if_not_exist_setting = '' # 提示信息 msg_client_err = _('Error') msg_user_not_bound_err = _('Error') - msg_user_need_bound_warning = _('Error') msg_not_found_user_from_client_err = _('Error') def verify_state(self): @@ -49,11 +47,6 @@ class BaseLoginCallbackView(AuthMixin, FlashMessageMixin, View): def create_user_if_not_exist(self, user_id, **kwargs): user = None - if not getattr(settings, self.create_user_if_not_exist_setting): - title = self.msg_client_err - msg = self.msg_user_need_bound_warning - return user, (title, msg) - user_attr = self.client.get_user_detail(user_id, **kwargs) try: user, create = User.objects.get_or_create( diff --git a/apps/authentication/views/dingtalk.py b/apps/authentication/views/dingtalk.py index a49d2a38f..77cec63fd 100644 --- a/apps/authentication/views/dingtalk.py +++ b/apps/authentication/views/dingtalk.py @@ -205,11 +205,9 @@ class DingTalkQRLoginCallbackView(DingTalkQRMixin, BaseLoginCallbackView): } user_type = 'dingtalk' auth_backend = 'AUTH_BACKEND_DINGTALK' - create_user_if_not_exist_setting = 'DINGTALK_CREATE_USER_IF_NOT_EXIST' msg_client_err = _('DingTalk Error') msg_user_not_bound_err = _('DingTalk is not bound') - msg_user_need_bound_warning = _('Please login with a password and then bind the DingTalk') msg_not_found_user_from_client_err = _('Failed to get user from DingTalk') diff --git a/apps/authentication/views/feishu.py b/apps/authentication/views/feishu.py index b4c16fb53..62660764a 100644 --- a/apps/authentication/views/feishu.py +++ b/apps/authentication/views/feishu.py @@ -162,10 +162,8 @@ class FeiShuQRLoginCallbackView(FeiShuQRMixin, BaseLoginCallbackView): client_auth_params = {'app_id': 'FEISHU_APP_ID', 'app_secret': 'FEISHU_APP_SECRET'} user_type = 'feishu' auth_backend = 'AUTH_BACKEND_FEISHU' - create_user_if_not_exist_setting = 'FEISHU_CREATE_USER_IF_NOT_EXIST' msg_client_err = _('FeiShu Error') msg_user_not_bound_err = _('FeiShu is not bound') - msg_user_need_bound_warning = _('Please login with a password and then bind the FeiShu') msg_not_found_user_from_client_err = _('Failed to get user from FeiShu') diff --git a/apps/authentication/views/wecom.py b/apps/authentication/views/wecom.py index b2061a4d6..e127dbeee 100644 --- a/apps/authentication/views/wecom.py +++ b/apps/authentication/views/wecom.py @@ -197,11 +197,9 @@ class WeComQRLoginCallbackView(WeComQRMixin, BaseLoginCallbackView): client_auth_params = {'corpid': 'WECOM_CORPID', 'corpsecret': 'WECOM_SECRET', 'agentid': 'WECOM_AGENTID'} user_type = 'wecom' auth_backend = 'AUTH_BACKEND_WECOM' - create_user_if_not_exist_setting = 'WECOM_CREATE_USER_IF_NOT_EXIST' msg_client_err = _('WeCom Error') msg_user_not_bound_err = _('WeCom is not bound') - msg_user_need_bound_warning = _('Please login with a password and then bind the WeCom') msg_not_found_user_from_client_err = _('Failed to get user from WeCom') diff --git a/apps/jumpserver/conf.py b/apps/jumpserver/conf.py index ba2593efd..343224675 100644 --- a/apps/jumpserver/conf.py +++ b/apps/jumpserver/conf.py @@ -365,21 +365,18 @@ class Config(dict): 'WECOM_CORPID': '', 'WECOM_AGENTID': '', 'WECOM_SECRET': '', - 'WECOM_CREATE_USER_IF_NOT_EXIST': False, # 钉钉 'AUTH_DINGTALK': False, 'DINGTALK_AGENTID': '', 'DINGTALK_APPKEY': '', 'DINGTALK_APPSECRET': '', - 'DINGTALK_CREATE_USER_IF_NOT_EXIST': False, # 飞书 'AUTH_FEISHU': False, 'FEISHU_APP_ID': '', 'FEISHU_APP_SECRET': '', 'FEISHU_VERSION': 'feishu', - 'FEISHU_CREATE_USER_IF_NOT_EXIST': False, 'LOGIN_REDIRECT_TO_BACKEND': '', # 'OPENID / CAS / SAML2 'LOGIN_REDIRECT_MSG_ENABLED': True, diff --git a/apps/settings/serializers/auth/dingtalk.py b/apps/settings/serializers/auth/dingtalk.py index f74d267b8..4ec7814a1 100644 --- a/apps/settings/serializers/auth/dingtalk.py +++ b/apps/settings/serializers/auth/dingtalk.py @@ -13,6 +13,3 @@ class DingTalkSettingSerializer(serializers.Serializer): DINGTALK_APPKEY = serializers.CharField(max_length=256, required=True, label='AppKey') DINGTALK_APPSECRET = EncryptedField(max_length=256, required=False, label='AppSecret') AUTH_DINGTALK = serializers.BooleanField(default=False, label=_('Enable DingTalk Auth')) - DINGTALK_CREATE_USER_IF_NOT_EXIST = serializers.BooleanField( - default=False, label=_('Create user if not') - ) diff --git a/apps/settings/serializers/auth/feishu.py b/apps/settings/serializers/auth/feishu.py index 0e12f04ab..a06d41b23 100644 --- a/apps/settings/serializers/auth/feishu.py +++ b/apps/settings/serializers/auth/feishu.py @@ -19,6 +19,3 @@ class FeiShuSettingSerializer(serializers.Serializer): FEISHU_VERSION = serializers.ChoiceField( choices=VERSION_CHOICES, default='feishu', label=_('Version') ) - FEISHU_CREATE_USER_IF_NOT_EXIST = serializers.BooleanField( - default=False, label=_('Create user if not') - ) diff --git a/apps/settings/serializers/auth/wecom.py b/apps/settings/serializers/auth/wecom.py index 3e57683a6..462b17db6 100644 --- a/apps/settings/serializers/auth/wecom.py +++ b/apps/settings/serializers/auth/wecom.py @@ -13,6 +13,3 @@ class WeComSettingSerializer(serializers.Serializer): WECOM_AGENTID = serializers.CharField(max_length=256, required=True, label='agentid') WECOM_SECRET = EncryptedField(max_length=256, required=False, label='secret') AUTH_WECOM = serializers.BooleanField(default=False, label=_('Enable WeCom Auth')) - WECOM_CREATE_USER_IF_NOT_EXIST = serializers.BooleanField( - default=False, label=_('Create user if not') - )