mirror of https://github.com/jumpserver/jumpserver
perf: Add viewAssetOnlineSessionInfo conf
parent
690f525afc
commit
e72073f0cc
|
@ -234,6 +234,7 @@ class Config(dict):
|
||||||
'SESSION_COOKIE_NAME_PREFIX': None,
|
'SESSION_COOKIE_NAME_PREFIX': None,
|
||||||
'SESSION_COOKIE_AGE': 3600 * 24,
|
'SESSION_COOKIE_AGE': 3600 * 24,
|
||||||
'SESSION_EXPIRE_AT_BROWSER_CLOSE': False,
|
'SESSION_EXPIRE_AT_BROWSER_CLOSE': False,
|
||||||
|
'VIEW_ASSET_ONLINE_SESSION_INFO': True,
|
||||||
'LOGIN_URL': reverse_lazy('authentication:login'),
|
'LOGIN_URL': reverse_lazy('authentication:login'),
|
||||||
|
|
||||||
'CONNECTION_TOKEN_ONETIME_EXPIRATION': 5 * 60, # 默认(new)
|
'CONNECTION_TOKEN_ONETIME_EXPIRATION': 5 * 60, # 默认(new)
|
||||||
|
|
|
@ -236,6 +236,7 @@ SESSION_COOKIE_NAME = '{}sessionid'.format(SESSION_COOKIE_NAME_PREFIX)
|
||||||
SESSION_COOKIE_AGE = CONFIG.SESSION_COOKIE_AGE
|
SESSION_COOKIE_AGE = CONFIG.SESSION_COOKIE_AGE
|
||||||
SESSION_SAVE_EVERY_REQUEST = CONFIG.SESSION_SAVE_EVERY_REQUEST
|
SESSION_SAVE_EVERY_REQUEST = CONFIG.SESSION_SAVE_EVERY_REQUEST
|
||||||
SESSION_EXPIRE_AT_BROWSER_CLOSE = CONFIG.SESSION_EXPIRE_AT_BROWSER_CLOSE
|
SESSION_EXPIRE_AT_BROWSER_CLOSE = CONFIG.SESSION_EXPIRE_AT_BROWSER_CLOSE
|
||||||
|
VIEW_ASSET_ONLINE_SESSION_INFO = CONFIG.VIEW_ASSET_ONLINE_SESSION_INFO
|
||||||
SESSION_ENGINE = "common.sessions.{}".format(CONFIG.SESSION_ENGINE)
|
SESSION_ENGINE = "common.sessions.{}".format(CONFIG.SESSION_ENGINE)
|
||||||
|
|
||||||
MESSAGE_STORAGE = 'django.contrib.messages.storage.cookie.CookieStorage'
|
MESSAGE_STORAGE = 'django.contrib.messages.storage.cookie.CookieStorage'
|
||||||
|
|
|
@ -30,6 +30,7 @@ class PrivateSettingSerializer(PublicSettingSerializer):
|
||||||
SECURITY_LUNA_REMEMBER_AUTH = serializers.BooleanField()
|
SECURITY_LUNA_REMEMBER_AUTH = serializers.BooleanField()
|
||||||
SECURITY_WATERMARK_ENABLED = serializers.BooleanField()
|
SECURITY_WATERMARK_ENABLED = serializers.BooleanField()
|
||||||
SESSION_EXPIRE_AT_BROWSER_CLOSE = serializers.BooleanField()
|
SESSION_EXPIRE_AT_BROWSER_CLOSE = serializers.BooleanField()
|
||||||
|
VIEW_ASSET_ONLINE_SESSION_INFO = serializers.BooleanField()
|
||||||
PASSWORD_RULE = serializers.DictField()
|
PASSWORD_RULE = serializers.DictField()
|
||||||
SECURITY_SESSION_SHARE = serializers.BooleanField()
|
SECURITY_SESSION_SHARE = serializers.BooleanField()
|
||||||
XPACK_LICENSE_IS_VALID = serializers.BooleanField()
|
XPACK_LICENSE_IS_VALID = serializers.BooleanField()
|
||||||
|
|
|
@ -4,6 +4,7 @@ import os
|
||||||
import tarfile
|
import tarfile
|
||||||
|
|
||||||
from django.core.files.storage import default_storage
|
from django.core.files.storage import default_storage
|
||||||
|
from django.conf import settings
|
||||||
from django.db.models import F
|
from django.db.models import F
|
||||||
from django.http import FileResponse
|
from django.http import FileResponse
|
||||||
from django.shortcuts import get_object_or_404, reverse
|
from django.shortcuts import get_object_or_404, reverse
|
||||||
|
@ -156,6 +157,8 @@ class SessionViewSet(RecordViewLogMixin, OrgBulkModelViewSet):
|
||||||
|
|
||||||
@action(methods=[GET], detail=False, permission_classes=[IsAuthenticated], url_path='online-info', )
|
@action(methods=[GET], detail=False, permission_classes=[IsAuthenticated], url_path='online-info', )
|
||||||
def online_info(self, request, *args, **kwargs):
|
def online_info(self, request, *args, **kwargs):
|
||||||
|
if not settings.VIEW_ASSET_ONLINE_SESSION_INFO:
|
||||||
|
return self.permission_denied(request, "view asset online session info disabled")
|
||||||
asset = self.request.query_params.get('asset_id')
|
asset = self.request.query_params.get('asset_id')
|
||||||
account = self.request.query_params.get('account')
|
account = self.request.query_params.get('account')
|
||||||
if asset is None or account is None:
|
if asset is None or account is None:
|
||||||
|
|
Loading…
Reference in New Issue