mirror of https://github.com/jumpserver/jumpserver
perf: 修改 chrome error
commit
e9125d1228
|
@ -1,6 +1,7 @@
|
|||
from django_filters import rest_framework as drf_filters
|
||||
|
||||
from common.api import JMSBulkModelViewSet
|
||||
from orgs.utils import tmp_to_root_org
|
||||
from .common import ACLUserFilterMixin
|
||||
from .. import serializers
|
||||
from ..models import ConnectMethodACL
|
||||
|
@ -21,3 +22,8 @@ class ConnectMethodACLViewSet(JMSBulkModelViewSet):
|
|||
filterset_class = ConnectMethodFilter
|
||||
search_fields = ('name',)
|
||||
serializer_class = serializers.ConnectMethodACLSerializer
|
||||
|
||||
def filter_queryset(self, queryset):
|
||||
with tmp_to_root_org():
|
||||
return super().filter_queryset(queryset)
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
from common.api import JMSBulkModelViewSet
|
||||
|
||||
from orgs.utils import tmp_to_root_org
|
||||
from .common import ACLUserFilterMixin
|
||||
from .. import serializers
|
||||
from ..models import LoginACL
|
||||
|
@ -17,3 +19,8 @@ class LoginACLViewSet(JMSBulkModelViewSet):
|
|||
filterset_class = LoginACLFilter
|
||||
search_fields = ('name',)
|
||||
serializer_class = serializers.LoginACLSerializer
|
||||
|
||||
def filter_queryset(self, queryset):
|
||||
with tmp_to_root_org():
|
||||
return super().filter_queryset(queryset)
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ __all__ = [
|
|||
'BaseACL', 'UserBaseACL', 'UserAssetAccountBaseACL',
|
||||
]
|
||||
|
||||
from orgs.utils import tmp_to_root_org
|
||||
from orgs.utils import tmp_to_org
|
||||
|
||||
|
||||
|
@ -90,7 +91,8 @@ class UserBaseACL(BaseACL):
|
|||
@classmethod
|
||||
def get_user_acls(cls, user):
|
||||
queryset = cls.objects.all()
|
||||
q = cls.users.get_filter_q(user)
|
||||
with tmp_to_root_org():
|
||||
q = cls.users.get_filter_q(user)
|
||||
queryset = queryset.filter(q)
|
||||
return queryset.filter(is_active=True).distinct()
|
||||
|
||||
|
@ -101,8 +103,6 @@ class UserAssetAccountBaseACL(OrgModelMixin, UserBaseACL):
|
|||
accounts = models.JSONField(default=list, verbose_name=_("Accounts"))
|
||||
objects = OrgManager.from_queryset(BaseACLQuerySet)()
|
||||
|
||||
objects = OrgManager.from_queryset(BaseACLQuerySet)()
|
||||
|
||||
class Meta(UserBaseACL.Meta):
|
||||
unique_together = [('name', 'org_id')]
|
||||
abstract = True
|
||||
|
|
|
@ -2,7 +2,7 @@ from typing import List
|
|||
|
||||
from rest_framework.request import Request
|
||||
|
||||
from assets.models import Node, PlatformProtocol
|
||||
from assets.models import Node, PlatformProtocol, Protocol
|
||||
from assets.utils import get_node_from_request, is_query_node_all_assets
|
||||
from common.utils import lazyproperty, timeit
|
||||
|
||||
|
@ -78,7 +78,10 @@ class SerializeToTreeNodeMixin:
|
|||
get_pid = lambda asset: getattr(asset, 'parent_key', '')
|
||||
else:
|
||||
get_pid = lambda asset: node_key
|
||||
|
||||
ssh_asset_ids = [
|
||||
str(i) for i in
|
||||
Protocol.objects.filter(name='ssh').values_list('asset_id', flat=True)
|
||||
]
|
||||
data = [
|
||||
{
|
||||
'id': str(asset.id),
|
||||
|
@ -96,7 +99,8 @@ class SerializeToTreeNodeMixin:
|
|||
'data': {
|
||||
'platform_type': asset.platform.type,
|
||||
'org_name': asset.org_name,
|
||||
'sftp': asset.platform_id in sftp_enabled_platform,
|
||||
'sftp': (asset.platform_id in sftp_enabled_platform) \
|
||||
and (str(asset.id) in ssh_asset_ids),
|
||||
'name': asset.name,
|
||||
'address': asset.address
|
||||
},
|
||||
|
|
|
@ -369,6 +369,7 @@ class AuthACLMixin:
|
|||
logger.debug('Login confirm acl id: {}'.format(acl_id))
|
||||
if not acl_id:
|
||||
return
|
||||
|
||||
acl = LoginACL.get_user_acls(user).filter(id=acl_id).first()
|
||||
if not acl:
|
||||
return
|
||||
|
|
|
@ -16,6 +16,7 @@ from common.exceptions import JMSException
|
|||
from common.utils import lazyproperty, pretty_string, bulk_get
|
||||
from common.utils.timezone import as_current_tz
|
||||
from orgs.mixins.models import JMSOrgBaseModel
|
||||
from orgs.utils import tmp_to_org
|
||||
from terminal.models import Applet
|
||||
|
||||
|
||||
|
@ -255,7 +256,8 @@ class ConnectionToken(JMSOrgBaseModel):
|
|||
'asset': self.asset,
|
||||
'account': self.account_object,
|
||||
}
|
||||
acls = CommandFilterACL.filter_queryset(**kwargs).valid()
|
||||
with tmp_to_org(self.asset.org_id):
|
||||
acls = CommandFilterACL.filter_queryset(**kwargs).valid()
|
||||
return acls
|
||||
|
||||
|
||||
|
|
|
@ -392,7 +392,8 @@ class RelatedManager:
|
|||
return self.filter_queryset_by_model(value, to_model)
|
||||
|
||||
def get_attr_q(self):
|
||||
q = self._get_filter_attrs_q(self.value, apps.get_model(self.field.to))
|
||||
to_model = apps.get_model(self.field.to)
|
||||
q = self._get_filter_attrs_q(self.value, to_model)
|
||||
return q
|
||||
|
||||
def all(self):
|
||||
|
|
|
@ -212,9 +212,9 @@ class SessionReplayViewSet(AsyncApiMixin, viewsets.ViewSet):
|
|||
|
||||
storage = ReplayStorageHandler(session)
|
||||
local_path, url_or_err = storage.get_file_path_url()
|
||||
if url_or_err:
|
||||
if local_path is None:
|
||||
return Response({"error": url_or_err}, status=404)
|
||||
data = self.get_replay_data(session, url_or_err)
|
||||
data = self.get_replay_data(session, local_path)
|
||||
return Response(data)
|
||||
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ class UserGroupViewSet(OrgBulkModelViewSet):
|
|||
serializer_class = UserGroupSerializer
|
||||
ordering = ('name',)
|
||||
rbac_perms = (
|
||||
("add_all_users", "users.change_usergroup"),
|
||||
("add_all_users", "users.add_usergroup"),
|
||||
)
|
||||
|
||||
@action(methods=['post'], detail=True, url_path='add-all-users')
|
||||
|
|
Loading…
Reference in New Issue