mirror of https://github.com/jumpserver/jumpserver
feat: add license edition check
parent
2dae2b3789
commit
1a03f7b265
|
@ -5,6 +5,7 @@ from django.shortcuts import reverse
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
from authentication.mixins import MFAFaceMixin
|
from authentication.mixins import MFAFaceMixin
|
||||||
|
from common.const import LicenseEditionChoices
|
||||||
from settings.api import settings
|
from settings.api import settings
|
||||||
|
|
||||||
|
|
||||||
|
@ -32,7 +33,10 @@ class MFAFace(BaseMFA, MFAFaceMixin):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def global_enabled():
|
def global_enabled():
|
||||||
return settings.XPACK_LICENSE_IS_VALID and settings.FACE_RECOGNITION_ENABLED
|
return settings.XPACK_LICENSE_IS_VALID \
|
||||||
|
and LicenseEditionChoices.ULTIMATE == \
|
||||||
|
LicenseEditionChoices.from_key(settings.XPACK_LICENSE_EDITION) \
|
||||||
|
and settings.FACE_RECOGNITION_ENABLED
|
||||||
|
|
||||||
def get_enable_url(self) -> str:
|
def get_enable_url(self) -> str:
|
||||||
return reverse('authentication:user-face-enable')
|
return reverse('authentication:user-face-enable')
|
||||||
|
|
|
@ -76,3 +76,32 @@ class Language(models.TextChoices):
|
||||||
|
|
||||||
|
|
||||||
COUNTRY_CALLING_CODES = get_country_phone_choices()
|
COUNTRY_CALLING_CODES = get_country_phone_choices()
|
||||||
|
|
||||||
|
|
||||||
|
class LicenseEditionChoices(models.TextChoices):
|
||||||
|
COMMUNITY = 'community', _('Community edition')
|
||||||
|
BASIC = 'basic', _('Basic edition')
|
||||||
|
STANDARD = 'standard', _('Standard edition')
|
||||||
|
PROFESSIONAL = 'professional', _('Professional edition')
|
||||||
|
ULTIMATE = 'ultimate', _('Ultimate edition')
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def from_key(key: str):
|
||||||
|
for choice in LicenseEditionChoices:
|
||||||
|
if choice == key:
|
||||||
|
return choice
|
||||||
|
return LicenseEditionChoices.COMMUNITY
|
||||||
|
@staticmethod
|
||||||
|
def parse_license_edition(info):
|
||||||
|
count = info.get('license', {}).get('count', 0)
|
||||||
|
|
||||||
|
if 50 >= count > 0:
|
||||||
|
return LicenseEditionChoices.BASIC
|
||||||
|
elif count <= 500:
|
||||||
|
return LicenseEditionChoices.STANDARD
|
||||||
|
elif count < 5000:
|
||||||
|
return LicenseEditionChoices.PROFESSIONAL
|
||||||
|
elif count >= 5000:
|
||||||
|
return LicenseEditionChoices.ULTIMATE
|
||||||
|
else:
|
||||||
|
return LicenseEditionChoices.COMMUNITY
|
||||||
|
|
|
@ -18,11 +18,12 @@ if not XPACK_DISABLED:
|
||||||
XPACK_TEMPLATES_DIR = []
|
XPACK_TEMPLATES_DIR = []
|
||||||
XPACK_CONTEXT_PROCESSOR = []
|
XPACK_CONTEXT_PROCESSOR = []
|
||||||
XPACK_LICENSE_IS_VALID = False
|
XPACK_LICENSE_IS_VALID = False
|
||||||
|
XPACK_LICENSE_EDITION = ""
|
||||||
XPACK_LICENSE_INFO = {
|
XPACK_LICENSE_INFO = {
|
||||||
'corporation': corporation,
|
'corporation': corporation,
|
||||||
}
|
}
|
||||||
|
|
||||||
XPACK_LICENSE_CONTENT = ''
|
XPACK_LICENSE_CONTENT = 'community'
|
||||||
|
|
||||||
if XPACK_ENABLED:
|
if XPACK_ENABLED:
|
||||||
from xpack.utils import get_xpack_templates_dir, get_xpack_context_processor
|
from xpack.utils import get_xpack_templates_dir, get_xpack_context_processor
|
||||||
|
|
Loading…
Reference in New Issue