mirror of https://github.com/jumpserver/jumpserver
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
780 B
27 lines
780 B
# -*- coding: utf-8 -*-
|
|
#
|
|
from django.contrib.auth.mixins import UserPassesTestMixin
|
|
from rest_framework import permissions
|
|
from rest_framework.decorators import action
|
|
from rest_framework.request import Request
|
|
from rest_framework.response import Response
|
|
|
|
from common.permissions import IsValidUser
|
|
|
|
__all__ = ["PermissionsMixin"]
|
|
|
|
|
|
class PermissionsMixin(UserPassesTestMixin):
|
|
permission_classes = [permissions.IsAuthenticated]
|
|
request: Request
|
|
|
|
def get_permissions(self):
|
|
return self.permission_classes
|
|
|
|
def test_func(self):
|
|
permission_classes = self.get_permissions()
|
|
for permission_class in permission_classes:
|
|
if not permission_class().has_permission(self.request, self):
|
|
return False
|
|
return True
|