mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-07-05 02:56:31 +00:00
perf: leak password can bulk delete
This commit is contained in:
parent
570566d9dd
commit
284d793253
@ -4,8 +4,9 @@ from django.conf import settings
|
|||||||
from django.core.cache import cache
|
from django.core.cache import cache
|
||||||
from rest_framework.generics import ListAPIView, CreateAPIView
|
from rest_framework.generics import ListAPIView, CreateAPIView
|
||||||
from rest_framework.views import Response
|
from rest_framework.views import Response
|
||||||
from rest_framework.viewsets import ModelViewSet
|
from rest_framework_bulk.generics import BulkModelViewSet
|
||||||
|
|
||||||
|
from common.drf.filters import IDSpmFilterBackend
|
||||||
from users.utils import LoginIpBlockUtil
|
from users.utils import LoginIpBlockUtil
|
||||||
from ..models import LeakPasswords
|
from ..models import LeakPasswords
|
||||||
from ..serializers import SecurityBlockIPSerializer, LeakPasswordPSerializer
|
from ..serializers import SecurityBlockIPSerializer, LeakPasswordPSerializer
|
||||||
@ -60,7 +61,7 @@ class UnlockIPSecurityAPI(CreateAPIView):
|
|||||||
return Response(status=200)
|
return Response(status=200)
|
||||||
|
|
||||||
|
|
||||||
class LeakPasswordViewSet(ModelViewSet):
|
class LeakPasswordViewSet(BulkModelViewSet):
|
||||||
serializer_class = LeakPasswordPSerializer
|
serializer_class = LeakPasswordPSerializer
|
||||||
model = LeakPasswords
|
model = LeakPasswords
|
||||||
rbac_perms = {
|
rbac_perms = {
|
||||||
@ -71,3 +72,11 @@ class LeakPasswordViewSet(ModelViewSet):
|
|||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
return LeakPasswords.objects.using('sqlite').all()
|
return LeakPasswords.objects.using('sqlite').all()
|
||||||
|
|
||||||
|
def allow_bulk_destroy(self, qs, filtered):
|
||||||
|
return True
|
||||||
|
|
||||||
|
def filter_queryset(self, queryset):
|
||||||
|
queryset = super().filter_queryset(queryset)
|
||||||
|
queryset = IDSpmFilterBackend().filter_queryset(self.request, queryset, self)
|
||||||
|
return queryset
|
||||||
|
Loading…
Reference in New Issue
Block a user