mirror of https://github.com/jumpserver/jumpserver
perf: integrations application detail add account tab page
parent
f223960b6a
commit
5067b7635f
|
@ -26,7 +26,7 @@ class IntegrationApplicationViewSet(OrgBulkModelViewSet):
|
|||
}
|
||||
rbac_perms = {
|
||||
'get_once_secret': 'accounts.change_integrationapplication',
|
||||
'get_account_secret': 'view_integrationapplication',
|
||||
'get_account_secret': 'accounts.view_integrationapplication'
|
||||
}
|
||||
|
||||
@action(
|
||||
|
@ -43,7 +43,7 @@ class IntegrationApplicationViewSet(OrgBulkModelViewSet):
|
|||
if os.path.exists(readme_path):
|
||||
with open(readme_path, 'r') as f:
|
||||
readme = f.read()
|
||||
return Response(data={'readme': readme })
|
||||
return Response(data={'readme': readme})
|
||||
|
||||
@action(
|
||||
['GET'], detail=True, url_path='secret',
|
||||
|
@ -54,7 +54,8 @@ class IntegrationApplicationViewSet(OrgBulkModelViewSet):
|
|||
secret = instance.get_secret()
|
||||
return Response(data={'id': instance.id, 'secret': secret})
|
||||
|
||||
@action(['GET'], detail=False, url_path='account-secret')
|
||||
@action(['GET'], detail=False, url_path='account-secret',
|
||||
permission_classes=[RBACPermission])
|
||||
def get_account_secret(self, request, *args, **kwargs):
|
||||
serializer = self.get_serializer(data=request.query_params)
|
||||
if not serializer.is_valid():
|
||||
|
@ -71,4 +72,3 @@ class IntegrationApplicationViewSet(OrgBulkModelViewSet):
|
|||
account=f'{account.name}({account.username})', asset=f'{asset.name}({asset.address})',
|
||||
)
|
||||
return Response(data={'id': request.user.id, 'secret': account.secret})
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ from django_filters import rest_framework as drf_filters
|
|||
from assets.models import Node
|
||||
from common.drf.filters import BaseFilterSet
|
||||
from common.utils.timezone import local_zero_hour, local_now
|
||||
from .models import Account, GatheredAccount, ChangeSecretRecord, PushSecretRecord
|
||||
from .models import Account, GatheredAccount, ChangeSecretRecord, PushSecretRecord, IntegrationApplication
|
||||
|
||||
|
||||
class AccountFilterSet(BaseFilterSet):
|
||||
|
@ -38,6 +38,7 @@ class AccountFilterSet(BaseFilterSet):
|
|||
risk = drf_filters.CharFilter(
|
||||
method="filter_risk",
|
||||
)
|
||||
integrationapplication = drf_filters.CharFilter(method="filter_integrationapplication")
|
||||
long_time_no_change_secret = drf_filters.BooleanFilter(method="filter_long_time")
|
||||
long_time_no_verified = drf_filters.BooleanFilter(method="filter_long_time")
|
||||
|
||||
|
@ -73,6 +74,17 @@ class AccountFilterSet(BaseFilterSet):
|
|||
queryset = queryset.filter(risks__risk=value)
|
||||
return queryset
|
||||
|
||||
@staticmethod
|
||||
def filter_integrationapplication(queryset, name, value):
|
||||
if not value:
|
||||
return queryset
|
||||
|
||||
integrationapplication = IntegrationApplication.objects.filter(pk=value).first()
|
||||
if not integrationapplication:
|
||||
return IntegrationApplication.objects.none()
|
||||
queryset = integrationapplication.get_accounts()
|
||||
return queryset
|
||||
|
||||
@staticmethod
|
||||
def filter_latest(queryset, name, value):
|
||||
if not value:
|
||||
|
|
Loading…
Reference in New Issue