mirror of https://github.com/jumpserver/jumpserver
perf: 优化license判断
parent
fd3a4d887e
commit
c55e2db75e
|
@ -2,6 +2,8 @@
|
||||||
#
|
#
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from werkzeug.local import LocalProxy
|
from werkzeug.local import LocalProxy
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
from common.local import thread_local
|
from common.local import thread_local
|
||||||
|
|
||||||
|
|
||||||
|
@ -17,4 +19,11 @@ def get_current_request():
|
||||||
return _find('current_request')
|
return _find('current_request')
|
||||||
|
|
||||||
|
|
||||||
|
def has_valid_xpack_license():
|
||||||
|
if not settings.XPACK_ENABLED:
|
||||||
|
return False
|
||||||
|
from xpack.plugins.license.models import License
|
||||||
|
return License.has_valid_license()
|
||||||
|
|
||||||
|
|
||||||
current_request = LocalProxy(partial(_find, 'current_request'))
|
current_request = LocalProxy(partial(_find, 'current_request'))
|
||||||
|
|
|
@ -10,6 +10,7 @@ from django.core.mail import send_mail, get_connection
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
from django.templatetags.static import static
|
from django.templatetags.static import static
|
||||||
|
|
||||||
|
from jumpserver.utils import has_valid_xpack_license
|
||||||
from common.permissions import IsSuperUser
|
from common.permissions import IsSuperUser
|
||||||
from common.utils import get_logger
|
from common.utils import get_logger
|
||||||
from .. import serializers
|
from .. import serializers
|
||||||
|
@ -94,14 +95,6 @@ class PublicSettingApi(generics.RetrieveAPIView):
|
||||||
logo_urls.update({attr: getattr(obj, attr).url})
|
logo_urls.update({attr: getattr(obj, attr).url})
|
||||||
return logo_urls
|
return logo_urls
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def get_xpack_license_is_valid():
|
|
||||||
if not settings.XPACK_ENABLED:
|
|
||||||
return False
|
|
||||||
|
|
||||||
from xpack.plugins.license.models import License
|
|
||||||
return License.has_valid_license()
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_login_title():
|
def get_login_title():
|
||||||
default_title = _('Welcome to the JumpServer open source Bastion Host')
|
default_title = _('Welcome to the JumpServer open source Bastion Host')
|
||||||
|
@ -121,7 +114,7 @@ class PublicSettingApi(generics.RetrieveAPIView):
|
||||||
"SECURITY_MFA_VERIFY_TTL": settings.SECURITY_MFA_VERIFY_TTL,
|
"SECURITY_MFA_VERIFY_TTL": settings.SECURITY_MFA_VERIFY_TTL,
|
||||||
"SECURITY_COMMAND_EXECUTION": settings.SECURITY_COMMAND_EXECUTION,
|
"SECURITY_COMMAND_EXECUTION": settings.SECURITY_COMMAND_EXECUTION,
|
||||||
"SECURITY_PASSWORD_EXPIRATION_TIME": settings.SECURITY_PASSWORD_EXPIRATION_TIME,
|
"SECURITY_PASSWORD_EXPIRATION_TIME": settings.SECURITY_PASSWORD_EXPIRATION_TIME,
|
||||||
"XPACK_LICENSE_IS_VALID": self.get_xpack_license_is_valid(),
|
"XPACK_LICENSE_IS_VALID": has_valid_xpack_license(),
|
||||||
"LOGIN_TITLE": self.get_login_title(),
|
"LOGIN_TITLE": self.get_login_title(),
|
||||||
"LOGO_URLS": self.get_logo_urls(),
|
"LOGO_URLS": self.get_logo_urls(),
|
||||||
"TICKETS_ENABLED": settings.TICKETS_ENABLED,
|
"TICKETS_ENABLED": settings.TICKETS_ENABLED,
|
||||||
|
|
Loading…
Reference in New Issue