mirror of https://github.com/jumpserver/jumpserver
perf: 修改 acl 登录
parent
1c95b67154
commit
998505e999
|
@ -90,7 +90,7 @@ class UserBaseACL(BaseACL):
|
|||
queryset = cls.objects.all()
|
||||
q = cls.users.get_filter_q(user)
|
||||
queryset = queryset.filter(q)
|
||||
return queryset.valid().distinct()
|
||||
return queryset.filter(is_active=True).distinct()
|
||||
|
||||
|
||||
class UserAssetAccountBaseACL(UserBaseACL, OrgModelMixin):
|
||||
|
@ -125,4 +125,4 @@ class UserAssetAccountBaseACL(UserBaseACL, OrgModelMixin):
|
|||
kwargs['org_id'] = org_id
|
||||
if kwargs:
|
||||
queryset = queryset.filter(**kwargs)
|
||||
return queryset.valid().distinct().order_by('priority', 'date_created')
|
||||
return queryset.filter(is_active=True).distinct().order_by('priority', 'date_created')
|
||||
|
|
|
@ -20,10 +20,6 @@ class LoginACL(UserBaseACL):
|
|||
def is_action(self, action):
|
||||
return self.action == action
|
||||
|
||||
@classmethod
|
||||
def filter_acl(cls, user):
|
||||
return user.login_acls.all().valid().distinct()
|
||||
|
||||
def create_confirm_ticket(self, request):
|
||||
from tickets import const
|
||||
from tickets.models import ApplyLoginTicket
|
||||
|
|
|
@ -369,7 +369,7 @@ class AuthACLMixin:
|
|||
logger.debug('Login confirm acl id: {}'.format(acl_id))
|
||||
if not acl_id:
|
||||
return
|
||||
acl = LoginACL.filter_acl(user).filter(id=acl_id).first()
|
||||
acl = LoginACL.get_user_acls(user).filter(id=acl_id).first()
|
||||
if not acl:
|
||||
return
|
||||
if not acl.is_action(acl.ActionChoices.review):
|
||||
|
|
|
@ -10,7 +10,7 @@ from django.apps import apps
|
|||
from django.core.exceptions import ValidationError
|
||||
from django.core.validators import MinValueValidator, MaxValueValidator
|
||||
from django.db import models
|
||||
from django.db.models import Q, Manager
|
||||
from django.db.models import Q, Manager, QuerySet
|
||||
from django.utils.encoding import force_text
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from rest_framework.utils.encoders import JSONEncoder
|
||||
|
@ -486,6 +486,10 @@ class JSONManyToManyDescriptor:
|
|||
elif rule['match'] == 'm2m':
|
||||
if isinstance(value, Manager):
|
||||
value = value.values_list('id', flat=True)
|
||||
elif isinstance(value, QuerySet):
|
||||
value = value.values_list('id', flat=True)
|
||||
elif isinstance(value, models.Model):
|
||||
value = [value.id]
|
||||
value = set(map(str, value))
|
||||
rule_value = set(map(str, rule_value))
|
||||
res &= rule_value.issubset(value)
|
||||
|
|
Loading…
Reference in New Issue