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