diff --git a/apps/authentication/api/connection_token.py b/apps/authentication/api/connection_token.py index abc9b538e..f0a7e0a63 100644 --- a/apps/authentication/api/connection_token.py +++ b/apps/authentication/api/connection_token.py @@ -16,7 +16,8 @@ from orgs.mixins.api import RootOrgViewMixin from perms.models.base import Action from terminal.models import EndpointRule from ..serializers import ( - ConnectionTokenSerializer, ConnectionTokenSecretSerializer, SuperConnectionTokenSerializer + ConnectionTokenSerializer, ConnectionTokenSecretSerializer, SuperConnectionTokenSerializer, + ConnectionTokenDisplaySerializer, ) from ..models import ConnectionToken @@ -209,6 +210,8 @@ class ConnectionTokenViewSet(ConnectionTokenMixin, RootOrgViewMixin, JMSModelVie search_fields = filterset_fields serializer_classes = { 'default': ConnectionTokenSerializer, + 'list': ConnectionTokenDisplaySerializer, + 'retrieve': ConnectionTokenDisplaySerializer, 'get_secret_detail': ConnectionTokenSecretSerializer, } rbac_perms = { diff --git a/apps/authentication/serializers/connection_token.py b/apps/authentication/serializers/connection_token.py index 33e99677c..c2af89aff 100644 --- a/apps/authentication/serializers/connection_token.py +++ b/apps/authentication/serializers/connection_token.py @@ -14,7 +14,7 @@ from perms.serializers.base import ActionsField __all__ = [ 'ConnectionTokenSerializer', 'ConnectionTokenSecretSerializer', - 'SuperConnectionTokenSerializer' + 'SuperConnectionTokenSerializer', 'ConnectionTokenDisplaySerializer' ] @@ -85,6 +85,13 @@ class ConnectionTokenSerializer(OrgResourceModelSerializerMixin): } +class ConnectionTokenDisplaySerializer(ConnectionTokenSerializer): + class Meta(ConnectionTokenSerializer.Meta): + extra_kwargs = { + 'secret': {'write_only': True}, + } + + # # SuperConnectionTokenSerializer #