fix: add settings for license version and facelive

v4.5
Bai 2024-12-19 17:26:34 +08:00 committed by feng626
parent 053d640e4c
commit 9b5509409c
4 changed files with 15 additions and 4 deletions

View File

@ -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)

View File

@ -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'

View File

@ -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,
}

View File

@ -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()