
* initial implementation Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> Signed-off-by: Jens Langhammer <jens@goauthentik.io> * cleanup Signed-off-by: Jens Langhammer <jens@goauthentik.io> * add migrations Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix web Signed-off-by: Jens Langhammer <jens@goauthentik.io> * minor fixes Signed-off-by: Jens Langhammer <jens@goauthentik.io> * use search-select Signed-off-by: Jens Langhammer <jens@goauthentik.io> * update locale Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fixup Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix ip with port being sent to delegated ip Signed-off-by: Jens Langhammer <jens@goauthentik.io> * add radius tests Signed-off-by: Jens Langhammer <jens@goauthentik.io> * update docs Signed-off-by: Jens Langhammer <jens@goauthentik.io> --------- Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> Signed-off-by: Jens Langhammer <jens@goauthentik.io>
66 lines
1.9 KiB
Python
66 lines
1.9 KiB
Python
"""RadiusProvider API Views"""
|
|
from rest_framework.fields import CharField
|
|
from rest_framework.serializers import ModelSerializer
|
|
from rest_framework.viewsets import ModelViewSet, ReadOnlyModelViewSet
|
|
|
|
from authentik.core.api.providers import ProviderSerializer
|
|
from authentik.core.api.used_by import UsedByMixin
|
|
from authentik.providers.radius.models import RadiusProvider
|
|
|
|
|
|
class RadiusProviderSerializer(ProviderSerializer):
|
|
"""RadiusProvider Serializer"""
|
|
|
|
class Meta:
|
|
model = RadiusProvider
|
|
fields = ProviderSerializer.Meta.fields + [
|
|
"client_networks",
|
|
# Shared secret is not a write-only field, as
|
|
# an admin might have to view it
|
|
"shared_secret",
|
|
]
|
|
extra_kwargs = ProviderSerializer.Meta.extra_kwargs
|
|
|
|
|
|
class RadiusProviderViewSet(UsedByMixin, ModelViewSet):
|
|
"""RadiusProvider Viewset"""
|
|
|
|
queryset = RadiusProvider.objects.all()
|
|
serializer_class = RadiusProviderSerializer
|
|
ordering = ["name"]
|
|
search_fields = ["name", "client_networks"]
|
|
filterset_fields = {
|
|
"application": ["isnull"],
|
|
"name": ["iexact"],
|
|
"authorization_flow__slug": ["iexact"],
|
|
"client_networks": ["iexact"],
|
|
}
|
|
|
|
|
|
class RadiusOutpostConfigSerializer(ModelSerializer):
|
|
"""RadiusProvider Serializer"""
|
|
|
|
application_slug = CharField(source="application.slug")
|
|
auth_flow_slug = CharField(source="authorization_flow.slug")
|
|
|
|
class Meta:
|
|
model = RadiusProvider
|
|
fields = [
|
|
"pk",
|
|
"name",
|
|
"application_slug",
|
|
"auth_flow_slug",
|
|
"client_networks",
|
|
"shared_secret",
|
|
]
|
|
|
|
|
|
class RadiusOutpostConfigViewSet(ReadOnlyModelViewSet):
|
|
"""RadiusProvider Viewset"""
|
|
|
|
queryset = RadiusProvider.objects.filter(application__isnull=False)
|
|
serializer_class = RadiusOutpostConfigSerializer
|
|
ordering = ["name"]
|
|
search_fields = ["name"]
|
|
filterset_fields = ["name"]
|