From 9b5509409c5342177c57f77d62667a12b6968ee1 Mon Sep 17 00:00:00 2001 From: Bai Date: Thu, 19 Dec 2024 17:26:34 +0800 Subject: [PATCH] fix: add settings for license version and facelive --- apps/acls/serializers/base.py | 7 +++++++ apps/authentication/mfa/face.py | 9 +++++---- apps/jumpserver/settings/_xpack.py | 1 + apps/settings/serializers/public.py | 2 ++ 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/apps/acls/serializers/base.py b/apps/acls/serializers/base.py index 4dfa56b9f..24a962822 100644 --- a/apps/acls/serializers/base.py +++ b/apps/acls/serializers/base.py @@ -70,6 +70,13 @@ class ActionAclSerializer(serializers.Serializer): return if not settings.XPACK_LICENSE_IS_VALID: field_action._choices.pop(ActionChoices.review, None) + if not ( + settings.XPACK_LICENSE_IS_VALID and + settings.XPACK_LICENSE_EDITION_ULTIMATE and + settings.FACE_RECOGNITION_ENABLED + ): + field_action._choices.pop(ActionChoices.face_verify, None) + field_action._choices.pop(ActionChoices.face_online, None) for choice in self.Meta.action_choices_exclude: field_action._choices.pop(choice, None) diff --git a/apps/authentication/mfa/face.py b/apps/authentication/mfa/face.py index 4d847cb99..d04d1e6b1 100644 --- a/apps/authentication/mfa/face.py +++ b/apps/authentication/mfa/face.py @@ -30,10 +30,11 @@ class MFAFace(BaseMFA, AuthFaceMixin): @staticmethod def global_enabled(): - return settings.XPACK_LICENSE_IS_VALID \ - and LicenseEditionChoices.ULTIMATE == \ - LicenseEditionChoices.from_key(settings.XPACK_LICENSE_EDITION) \ - and settings.FACE_RECOGNITION_ENABLED + return ( + settings.XPACK_LICENSE_IS_VALID and + settings.XPACK_LICENSE_EDITION_ULTIMATE and + settings.FACE_RECOGNITION_ENABLED + ) def get_enable_url(self) -> str: return '/ui/#/profile/index' diff --git a/apps/jumpserver/settings/_xpack.py b/apps/jumpserver/settings/_xpack.py index f0e59cecf..76b1d81b3 100644 --- a/apps/jumpserver/settings/_xpack.py +++ b/apps/jumpserver/settings/_xpack.py @@ -19,6 +19,7 @@ XPACK_TEMPLATES_DIR = [] XPACK_CONTEXT_PROCESSOR = [] XPACK_LICENSE_IS_VALID = False XPACK_LICENSE_EDITION = "" +XPACK_LICENSE_EDITION_ULTIMATE = False XPACK_LICENSE_INFO = { 'corporation': corporation, } diff --git a/apps/settings/serializers/public.py b/apps/settings/serializers/public.py index 82a3c5118..3c7b11a6b 100644 --- a/apps/settings/serializers/public.py +++ b/apps/settings/serializers/public.py @@ -34,6 +34,8 @@ class PrivateSettingSerializer(PublicSettingSerializer): PASSWORD_RULE = serializers.DictField() SECURITY_SESSION_SHARE = serializers.BooleanField() XPACK_LICENSE_IS_VALID = serializers.BooleanField() + XPACK_LICENSE_EDITION_ULTIMATE = serializers.BooleanField() + FACE_RECOGNITION_ENABLED = serializers.BooleanField() XPACK_LICENSE_INFO = serializers.DictField() HELP_DOCUMENT_URL = serializers.CharField() HELP_SUPPORT_URL = serializers.CharField()