mirror of https://github.com/jumpserver/jumpserver
perf: 修改 gettext
parent
b4b9c805ff
commit
7ae52eb941
|
@ -6,6 +6,5 @@ class AccountsConfig(AppConfig):
|
||||||
name = 'accounts'
|
name = 'accounts'
|
||||||
|
|
||||||
def ready(self):
|
def ready(self):
|
||||||
from . import signal_handlers
|
from . import signal_handlers # noqa
|
||||||
from . import tasks
|
from . import tasks # noqa
|
||||||
__all__ = signal_handlers
|
|
||||||
|
|
|
@ -12,4 +12,6 @@ class AssetsConfig(AppConfig):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
def ready(self):
|
def ready(self):
|
||||||
|
from . import signal_handlers # noqa
|
||||||
|
from . import tasks # noqa
|
||||||
super().ready()
|
super().ready()
|
||||||
|
|
|
@ -9,7 +9,8 @@ class AuditsConfig(AppConfig):
|
||||||
verbose_name = _('Audits')
|
verbose_name = _('Audits')
|
||||||
|
|
||||||
def ready(self):
|
def ready(self):
|
||||||
from . import signal_handlers
|
from . import signal_handlers # noqa
|
||||||
|
from . import tasks # noqa
|
||||||
|
|
||||||
if settings.SYSLOG_ENABLE:
|
if settings.SYSLOG_ENABLE:
|
||||||
post_save.connect(signal_handlers.on_audits_log_create)
|
post_save.connect(signal_handlers.on_audits_log_create)
|
||||||
|
|
|
@ -7,4 +7,7 @@ class AuthenticationConfig(AppConfig):
|
||||||
verbose_name = _('Authentication')
|
verbose_name = _('Authentication')
|
||||||
|
|
||||||
def ready(self):
|
def ready(self):
|
||||||
|
from . import signal_handlers # noqa
|
||||||
|
from . import tasks # noqa
|
||||||
|
from . import notifications # noqa
|
||||||
super().ready()
|
super().ready()
|
||||||
|
|
|
@ -10,7 +10,6 @@ from apps.jumpserver.settings.auth import AUTHENTICATION_BACKENDS_THIRD_PARTY
|
||||||
from .signals import post_auth_success, post_auth_failed, user_auth_failed, user_auth_success
|
from .signals import post_auth_success, post_auth_failed, user_auth_failed, user_auth_success
|
||||||
|
|
||||||
|
|
||||||
@receiver(user_logged_in)
|
|
||||||
def on_user_auth_login_success(sender, user, request, **kwargs):
|
def on_user_auth_login_success(sender, user, request, **kwargs):
|
||||||
# 失效 perms 缓存
|
# 失效 perms 缓存
|
||||||
user.expire_rbac_perms_cache()
|
user.expire_rbac_perms_cache()
|
||||||
|
@ -52,3 +51,6 @@ def on_user_login_success(sender, request, user, backend, create=False, **kwargs
|
||||||
def on_user_login_failed(sender, username, request, reason, backend, **kwargs):
|
def on_user_login_failed(sender, username, request, reason, backend, **kwargs):
|
||||||
request.session['auth_backend'] = backend
|
request.session['auth_backend'] = backend
|
||||||
post_auth_failed.send(sender, username=username, request=request, reason=reason)
|
post_auth_failed.send(sender, username=username, request=request, reason=reason)
|
||||||
|
|
||||||
|
|
||||||
|
user_logged_in.connect(on_user_auth_login_success)
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from django.apps import AppConfig
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,8 +9,8 @@ class CommonConfig(AppConfig):
|
||||||
name = 'common'
|
name = 'common'
|
||||||
|
|
||||||
def ready(self):
|
def ready(self):
|
||||||
from . import signal_handlers
|
from . import signal_handlers # noqa
|
||||||
from . import tasks
|
from . import tasks # noqa
|
||||||
from .signals import django_ready
|
from .signals import django_ready
|
||||||
excludes = ['migrate', 'compilemessages', 'makemigrations']
|
excludes = ['migrate', 'compilemessages', 'makemigrations']
|
||||||
for i in excludes:
|
for i in excludes:
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import pytz
|
|
||||||
from datetime import datetime, timedelta, timezone
|
from datetime import datetime, timedelta, timezone
|
||||||
|
|
||||||
|
import pytz
|
||||||
from django.utils import timezone as dj_timezone
|
from django.utils import timezone as dj_timezone
|
||||||
from rest_framework.fields import DateTimeField
|
from rest_framework.fields import DateTimeField
|
||||||
|
|
||||||
|
@ -8,6 +9,7 @@ max = datetime.max.replace(tzinfo=timezone.utc)
|
||||||
|
|
||||||
def astimezone(dt: datetime, tzinfo: pytz.tzinfo.DstTzInfo):
|
def astimezone(dt: datetime, tzinfo: pytz.tzinfo.DstTzInfo):
|
||||||
assert dj_timezone.is_aware(dt)
|
assert dj_timezone.is_aware(dt)
|
||||||
|
print("dt.tzinfo: ", tzinfo, type(tzinfo))
|
||||||
return tzinfo.normalize(dt.astimezone(tzinfo))
|
return tzinfo.normalize(dt.astimezone(tzinfo))
|
||||||
|
|
||||||
|
|
||||||
|
@ -16,7 +18,7 @@ def as_china_cst(dt: datetime):
|
||||||
|
|
||||||
|
|
||||||
def as_current_tz(dt: datetime):
|
def as_current_tz(dt: datetime):
|
||||||
return astimezone(dt, dj_timezone.get_current_timezone())
|
return dt.astimezone(dj_timezone.get_current_timezone())
|
||||||
|
|
||||||
|
|
||||||
def utc_now():
|
def utc_now():
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
from channels.auth import AuthMiddlewareStack
|
from channels.auth import AuthMiddlewareStack
|
||||||
from channels.routing import ProtocolTypeRouter, URLRouter
|
from channels.routing import ProtocolTypeRouter, URLRouter
|
||||||
|
from channels.security.websocket import AllowedHostsOriginValidator
|
||||||
from django.core.asgi import get_asgi_application
|
from django.core.asgi import get_asgi_application
|
||||||
|
|
||||||
from ops.urls.ws_urls import urlpatterns as ops_urlpatterns
|
|
||||||
from notifications.urls.ws_urls import urlpatterns as notifications_urlpatterns
|
from notifications.urls.ws_urls import urlpatterns as notifications_urlpatterns
|
||||||
|
from ops.urls.ws_urls import urlpatterns as ops_urlpatterns
|
||||||
from settings.urls.ws_urls import urlpatterns as setting_urlpatterns
|
from settings.urls.ws_urls import urlpatterns as setting_urlpatterns
|
||||||
from terminal.urls.ws_urls import urlpatterns as terminal_urlpatterns
|
from terminal.urls.ws_urls import urlpatterns as terminal_urlpatterns
|
||||||
|
|
||||||
from .middleware import WsSignatureAuthMiddleware
|
from .middleware import WsSignatureAuthMiddleware
|
||||||
|
|
||||||
urlpatterns = []
|
urlpatterns = []
|
||||||
|
@ -16,6 +16,12 @@ urlpatterns += ops_urlpatterns + \
|
||||||
terminal_urlpatterns
|
terminal_urlpatterns
|
||||||
|
|
||||||
application = ProtocolTypeRouter({
|
application = ProtocolTypeRouter({
|
||||||
'websocket': WsSignatureAuthMiddleware(AuthMiddlewareStack(URLRouter(urlpatterns))),
|
|
||||||
"http": get_asgi_application(),
|
"http": get_asgi_application(),
|
||||||
|
'websocket': AllowedHostsOriginValidator(
|
||||||
|
WsSignatureAuthMiddleware(
|
||||||
|
AuthMiddlewareStack(
|
||||||
|
URLRouter(urlpatterns)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
})
|
})
|
||||||
|
|
|
@ -66,7 +66,8 @@ APPLET_DOWNLOAD_HOST = CONFIG.APPLET_DOWNLOAD_HOST
|
||||||
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
|
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
|
||||||
|
|
||||||
# https://docs.djangoproject.com/en/4.1/ref/settings/#std-setting-CSRF_TRUSTED_ORIGINS
|
# https://docs.djangoproject.com/en/4.1/ref/settings/#std-setting-CSRF_TRUSTED_ORIGINS
|
||||||
CSRF_TRUSTED_ORIGINS = CONFIG.CSRF_TRUSTED_ORIGINS.split(',') if CONFIG.CSRF_TRUSTED_ORIGINS else []
|
CSRF_TRUSTED_ORIGINS = CONFIG.CSRF_TRUSTED_ORIGINS.split(',') if CONFIG.CSRF_TRUSTED_ORIGINS \
|
||||||
|
else ['https://*', 'https://.*', 'http://localhost:9528']
|
||||||
|
|
||||||
# LOG LEVEL
|
# LOG LEVEL
|
||||||
LOG_LEVEL = CONFIG.LOG_LEVEL
|
LOG_LEVEL = CONFIG.LOG_LEVEL
|
||||||
|
|
|
@ -7,4 +7,6 @@ class NotificationsConfig(AppConfig):
|
||||||
verbose_name = _('Notifications')
|
verbose_name = _('Notifications')
|
||||||
|
|
||||||
def ready(self):
|
def ready(self):
|
||||||
|
from . import signal_handlers # noqa
|
||||||
|
from . import notifications # noqa
|
||||||
super().ready()
|
super().ready()
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from django.utils.translation import gettext_lazy as _
|
|
||||||
from django.apps import AppConfig
|
from django.apps import AppConfig
|
||||||
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
|
|
||||||
class OpsConfig(AppConfig):
|
class OpsConfig(AppConfig):
|
||||||
|
@ -12,8 +12,8 @@ class OpsConfig(AppConfig):
|
||||||
from orgs.models import Organization
|
from orgs.models import Organization
|
||||||
from orgs.utils import set_current_org
|
from orgs.utils import set_current_org
|
||||||
set_current_org(Organization.root())
|
set_current_org(Organization.root())
|
||||||
from .celery import signal_handler
|
from .celery import signal_handler # noqa
|
||||||
from . import signal_handlers
|
from . import signal_handlers # noqa
|
||||||
from . import notifications
|
from . import notifications # noqa
|
||||||
from . import tasks
|
from . import tasks # noqa
|
||||||
super().ready()
|
super().ready()
|
||||||
|
|
|
@ -7,4 +7,6 @@ class OrgsConfig(AppConfig):
|
||||||
verbose_name = _('App organizations')
|
verbose_name = _('App organizations')
|
||||||
|
|
||||||
def ready(self):
|
def ready(self):
|
||||||
pass
|
from . import signal_handlers # noqa
|
||||||
|
from . import tasks # noqa
|
||||||
|
super().ready()
|
||||||
|
|
|
@ -9,4 +9,7 @@ class PermsConfig(AppConfig):
|
||||||
verbose_name = _('App permissions')
|
verbose_name = _('App permissions')
|
||||||
|
|
||||||
def ready(self):
|
def ready(self):
|
||||||
|
from . import signal_handlers # noqa
|
||||||
|
from . import tasks # noqa
|
||||||
|
from . import notifications # noqa
|
||||||
super().ready()
|
super().ready()
|
||||||
|
|
|
@ -7,4 +7,5 @@ class RBACConfig(AppConfig):
|
||||||
verbose_name = _('RBAC')
|
verbose_name = _('RBAC')
|
||||||
|
|
||||||
def ready(self):
|
def ready(self):
|
||||||
|
from . import signal_handlers # noqa
|
||||||
super().ready()
|
super().ready()
|
||||||
|
|
|
@ -7,4 +7,5 @@ class SettingsConfig(AppConfig):
|
||||||
verbose_name = _('Settings')
|
verbose_name = _('Settings')
|
||||||
|
|
||||||
def ready(self):
|
def ready(self):
|
||||||
pass
|
from . import signal_handlers # noqa
|
||||||
|
from . import tasks # noqa
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from django.utils.translation import gettext_lazy as _
|
|
||||||
from django.apps import AppConfig
|
from django.apps import AppConfig
|
||||||
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
|
|
||||||
class TerminalConfig(AppConfig):
|
class TerminalConfig(AppConfig):
|
||||||
|
@ -9,7 +9,7 @@ class TerminalConfig(AppConfig):
|
||||||
verbose_name = _('Terminals')
|
verbose_name = _('Terminals')
|
||||||
|
|
||||||
def ready(self):
|
def ready(self):
|
||||||
from . import signal_handlers
|
from . import signal_handlers # noqa
|
||||||
from . import notifications
|
from . import notifications # noqa
|
||||||
from . import tasks
|
from . import tasks # noqa
|
||||||
return super().ready()
|
return super().ready()
|
||||||
|
|
|
@ -7,4 +7,6 @@ class TicketsConfig(AppConfig):
|
||||||
verbose_name = _('Tickets')
|
verbose_name = _('Tickets')
|
||||||
|
|
||||||
def ready(self):
|
def ready(self):
|
||||||
|
from . import signal_handlers # noqa
|
||||||
|
from . import notifications # noqa
|
||||||
return super().ready()
|
return super().ready()
|
||||||
|
|
|
@ -9,4 +9,7 @@ class UsersConfig(AppConfig):
|
||||||
verbose_name = _('Users')
|
verbose_name = _('Users')
|
||||||
|
|
||||||
def ready(self):
|
def ready(self):
|
||||||
|
from . import signal_handlers # noqa
|
||||||
|
from . import tasks # noqa
|
||||||
|
from . import notifications # noqa
|
||||||
super().ready()
|
super().ready()
|
||||||
|
|
|
@ -6,6 +6,7 @@ echo "1. 安装依赖"
|
||||||
brew install libtiff libjpeg webp little-cms2 openssl gettext git \
|
brew install libtiff libjpeg webp little-cms2 openssl gettext git \
|
||||||
git-lfs libxml2 libxmlsec1 pkg-config postgresql freetds openssl \
|
git-lfs libxml2 libxmlsec1 pkg-config postgresql freetds openssl \
|
||||||
libffi freerdp
|
libffi freerdp
|
||||||
|
pip install daphne channels channel-redis
|
||||||
|
|
||||||
echo "2. 下载 IP 数据库"
|
echo "2. 下载 IP 数据库"
|
||||||
ip_db_path="${PROJECT_DIR}/apps/common/utils/geoip/GeoLite2-City.mmdb"
|
ip_db_path="${PROJECT_DIR}/apps/common/utils/geoip/GeoLite2-City.mmdb"
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
cython==3.0.0
|
cython==3.0.0
|
||||||
aiofiles==23.1.0
|
aiofiles==23.1.0
|
||||||
amqp==5.1.1
|
amqp==5.1.1
|
||||||
#git+https://github.com/jumpserver/ansible@master#egg=ansible-core
|
git+https://github.com/jumpserver/ansible@master#egg=ansible-core
|
||||||
ansible==7.1.0
|
ansible==7.1.0
|
||||||
ansible-runner==2.3.3
|
ansible-runner==2.3.3
|
||||||
asn1crypto==1.5.1
|
asn1crypto==1.5.1
|
||||||
|
@ -108,7 +108,7 @@ websockets==11.0.3
|
||||||
python-ldap==3.4.3
|
python-ldap==3.4.3
|
||||||
ldap3==2.9.1
|
ldap3==2.9.1
|
||||||
#django-radius==1.5.0
|
#django-radius==1.5.0
|
||||||
#git+https://github.com/robgolding/django-radius@develop#egg=django-radius
|
git+https://github.com/robgolding/django-radius@develop#egg=django-radius
|
||||||
django-cas-ng==4.3.0
|
django-cas-ng==4.3.0
|
||||||
python-cas==1.6.0
|
python-cas==1.6.0
|
||||||
django-auth-ldap==4.4.0
|
django-auth-ldap==4.4.0
|
||||||
|
|
Loading…
Reference in New Issue