perf: Support batch import of leak passwords

This commit is contained in:
wangruidong
2025-11-05 16:20:20 +08:00
committed by 老广
parent a2aae9db47
commit e4f5e21219
2 changed files with 10 additions and 2 deletions

View File

@@ -1627,5 +1627,6 @@
"removeWarningMsg": "Are you sure you want to remove",
"setVariable": "Set variable",
"userId": "User ID",
"userName": "User name"
"userName": "User name",
"LeakPasswordList": "Leaked password list"
}

View File

@@ -6,6 +6,7 @@ from rest_framework.generics import ListAPIView, CreateAPIView
from rest_framework.views import Response
from rest_framework_bulk.generics import BulkModelViewSet
from common.api.action import RenderToJsonMixin
from common.drf.filters import IDSpmFilterBackend
from users.utils import LoginIpBlockUtil
from ..models import LeakPasswords
@@ -61,7 +62,7 @@ class UnlockIPSecurityAPI(CreateAPIView):
return Response(status=200)
class LeakPasswordViewSet(BulkModelViewSet):
class LeakPasswordViewSet(BulkModelViewSet, RenderToJsonMixin):
serializer_class = LeakPasswordPSerializer
model = LeakPasswords
rbac_perms = {
@@ -70,6 +71,12 @@ class LeakPasswordViewSet(BulkModelViewSet):
queryset = LeakPasswords.objects.none()
search_fields = ['password']
def get_object(self):
pk = self.kwargs.get('pk')
if pk:
return self.get_queryset().get(id=pk)
return super().get_object()
def get_queryset(self):
return LeakPasswords.objects.using('sqlite').all()