mirror of https://github.com/jumpserver/jumpserver
fix: 命令存储 or 命令权限
parent
4c31b5ec0f
commit
c4a6715eb8
|
@ -14,7 +14,6 @@ from terminal.filters import CommandStorageFilter, CommandFilter, CommandFilterF
|
|||
from ..models import CommandStorage, ReplayStorage
|
||||
from ..serializers import CommandStorageSerializer, ReplayStorageSerializer
|
||||
|
||||
|
||||
__all__ = [
|
||||
'CommandStorageViewSet', 'CommandStorageTestConnectiveApi',
|
||||
'ReplayStorageViewSet', 'ReplayStorageTestConnectiveApi'
|
||||
|
@ -40,7 +39,7 @@ class CommandStorageViewSet(BaseStorageViewSetMixin, viewsets.ModelViewSet):
|
|||
serializer_class = CommandStorageSerializer
|
||||
filterset_class = CommandStorageFilter
|
||||
rbac_perms = {
|
||||
'tree': 'terminal.view_commandstorage'
|
||||
'tree': 'terminal.view_commandstorage | terminal.view_command'
|
||||
}
|
||||
|
||||
@action(methods=[GET], detail=False, filterset_class=CommandFilterForStorageTree)
|
||||
|
|
|
@ -806,6 +806,15 @@ class User(AuthMixin, TokenMixin, RoleMixin, MFAMixin, AbstractUser):
|
|||
return True
|
||||
return False
|
||||
|
||||
def has_perms(self, perm_list, obj=None):
|
||||
"""
|
||||
Return True if the user has each of the specified permissions. If
|
||||
object is passed, check if the user has all required perms for it.
|
||||
"""
|
||||
if '*' in perm_list:
|
||||
return True
|
||||
return all(any(self.has_perm(perm, obj) for perm in perms.split(' | ')) for perms in perm_list)
|
||||
|
||||
|
||||
class UserPasswordHistory(models.Model):
|
||||
id = models.UUIDField(default=uuid.uuid4, primary_key=True)
|
||||
|
|
Loading…
Reference in New Issue