providers/*: add assigned application name and slug
This commit is contained in:
parent
1b3760a4b7
commit
c7c387eb38
|
@ -1,4 +1,5 @@
|
|||
"""Provider API Views"""
|
||||
from rest_framework.fields import ReadOnlyField
|
||||
from rest_framework.serializers import ModelSerializer, SerializerMethodField
|
||||
from rest_framework.viewsets import ModelViewSet
|
||||
|
||||
|
@ -44,6 +45,10 @@ class ProviderViewSet(ModelViewSet):
|
|||
filterset_fields = {
|
||||
"application": ["isnull"],
|
||||
}
|
||||
search_fields = [
|
||||
"name",
|
||||
"application__name",
|
||||
]
|
||||
|
||||
def get_queryset(self):
|
||||
return Provider.objects.select_subclasses()
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
"""OAuth2Provider API Views"""
|
||||
from rest_framework.fields import ReadOnlyField
|
||||
from rest_framework.serializers import ModelSerializer
|
||||
from rest_framework.viewsets import ModelViewSet
|
||||
|
||||
|
@ -9,6 +10,9 @@ from authentik.providers.oauth2.models import OAuth2Provider, ScopeMapping
|
|||
class OAuth2ProviderSerializer(ModelSerializer, MetaNameSerializer):
|
||||
"""OAuth2Provider Serializer"""
|
||||
|
||||
assigned_application_slug = ReadOnlyField(source="application.slug")
|
||||
assigned_application_name = ReadOnlyField(source="application.name")
|
||||
|
||||
class Meta:
|
||||
|
||||
model = OAuth2Provider
|
||||
|
@ -27,6 +31,8 @@ class OAuth2ProviderSerializer(ModelSerializer, MetaNameSerializer):
|
|||
"sub_mode",
|
||||
"property_mappings",
|
||||
"issuer_mode",
|
||||
"assigned_application_slug",
|
||||
"assigned_application_name",
|
||||
"verbose_name",
|
||||
"verbose_name_plural",
|
||||
]
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
"""ProxyProvider API Views"""
|
||||
from drf_yasg2.utils import swagger_serializer_method
|
||||
from rest_framework.fields import CharField, ListField, SerializerMethodField
|
||||
from rest_framework.fields import CharField, ListField, ReadOnlyField, SerializerMethodField
|
||||
from rest_framework.request import Request
|
||||
from rest_framework.response import Response
|
||||
from rest_framework.serializers import ModelSerializer, Serializer
|
||||
|
@ -37,6 +37,9 @@ class OpenIDConnectConfigurationSerializer(Serializer):
|
|||
class ProxyProviderSerializer(MetaNameSerializer, ModelSerializer):
|
||||
"""ProxyProvider Serializer"""
|
||||
|
||||
assigned_application_slug = ReadOnlyField(source="application.slug")
|
||||
assigned_application_name = ReadOnlyField(source="application.name")
|
||||
|
||||
def create(self, validated_data):
|
||||
instance: ProxyProvider = super().create(validated_data)
|
||||
instance.set_oauth_defaults()
|
||||
|
@ -61,6 +64,8 @@ class ProxyProviderSerializer(MetaNameSerializer, ModelSerializer):
|
|||
"basic_auth_enabled",
|
||||
"basic_auth_password_attribute",
|
||||
"basic_auth_user_attribute",
|
||||
"assigned_application_slug",
|
||||
"assigned_application_name",
|
||||
"verbose_name",
|
||||
"verbose_name_plural",
|
||||
]
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
"""SAMLProvider API Views"""
|
||||
from rest_framework.serializers import ModelSerializer
|
||||
from typing import Optional
|
||||
from authentik.core.models import Application
|
||||
from rest_framework.fields import ReadOnlyField, SerializerMethodField
|
||||
from rest_framework.serializers import ModelSerializer, Serializer, CharField
|
||||
from rest_framework.viewsets import ModelViewSet
|
||||
|
||||
from authentik.core.api.utils import MetaNameSerializer
|
||||
|
@ -9,6 +12,9 @@ from authentik.providers.saml.models import SAMLPropertyMapping, SAMLProvider
|
|||
class SAMLProviderSerializer(ModelSerializer, MetaNameSerializer):
|
||||
"""SAMLProvider Serializer"""
|
||||
|
||||
assigned_application_slug = ReadOnlyField(source="application.slug")
|
||||
assigned_application_name = ReadOnlyField(source="application.name")
|
||||
|
||||
class Meta:
|
||||
|
||||
model = SAMLProvider
|
||||
|
@ -27,6 +33,8 @@ class SAMLProviderSerializer(ModelSerializer, MetaNameSerializer):
|
|||
"signature_algorithm",
|
||||
"signing_kp",
|
||||
"verification_kp",
|
||||
"assigned_application_slug",
|
||||
"assigned_application_name",
|
||||
"verbose_name",
|
||||
"verbose_name_plural",
|
||||
]
|
||||
|
|
Reference in New Issue