diff --git a/authentik/providers/oauth2/api/scope.py b/authentik/providers/oauth2/api/scope.py index 643cecb21..645427d50 100644 --- a/authentik/providers/oauth2/api/scope.py +++ b/authentik/providers/oauth2/api/scope.py @@ -1,4 +1,6 @@ """OAuth2Provider API Views""" +from django_filters.filters import AllValuesMultipleFilter +from django_filters.filterset import FilterSet from rest_framework.viewsets import ModelViewSet from authentik.core.api.propertymappings import PropertyMappingSerializer @@ -18,10 +20,20 @@ class ScopeMappingSerializer(PropertyMappingSerializer): ] +class ScopeMappingFilter(FilterSet): + """Filter for ScopeMapping""" + + managed = AllValuesMultipleFilter(field_name="managed") + + class Meta: + model = ScopeMapping + fields = ["scope_name", "name", "managed"] + + class ScopeMappingViewSet(UsedByMixin, ModelViewSet): """ScopeMapping Viewset""" queryset = ScopeMapping.objects.all() serializer_class = ScopeMappingSerializer - filterset_fields = ["scope_name", "name", "managed"] + filterset_class = ScopeMappingFilter ordering = ["scope_name", "name"] diff --git a/authentik/providers/saml/api.py b/authentik/providers/saml/api.py index 718bae775..8d8f2e978 100644 --- a/authentik/providers/saml/api.py +++ b/authentik/providers/saml/api.py @@ -6,6 +6,8 @@ from django.http.response import Http404, HttpResponse from django.shortcuts import get_object_or_404 from django.urls import reverse from django.utils.translation import gettext_lazy as _ +from django_filters.filters import AllValuesMultipleFilter +from django_filters.filterset import FilterSet from drf_spectacular.types import OpenApiTypes from drf_spectacular.utils import OpenApiParameter, OpenApiResponse, extend_schema from rest_framework.decorators import action @@ -180,10 +182,20 @@ class SAMLPropertyMappingSerializer(PropertyMappingSerializer): ] +class SAMLPropertyMappingFilter(FilterSet): + """Filter for SAMLPropertyMapping""" + + managed = AllValuesMultipleFilter(field_name="managed") + + class Meta: + model = SAMLPropertyMapping + fields = "__all__" + + class SAMLPropertyMappingViewSet(UsedByMixin, ModelViewSet): """SAMLPropertyMapping Viewset""" queryset = SAMLPropertyMapping.objects.all() serializer_class = SAMLPropertyMappingSerializer - filterset_fields = "__all__" + filterset_class = SAMLPropertyMappingFilter ordering = ["name"] diff --git a/authentik/sources/ldap/api.py b/authentik/sources/ldap/api.py index 6860405c9..014c75cf2 100644 --- a/authentik/sources/ldap/api.py +++ b/authentik/sources/ldap/api.py @@ -1,6 +1,8 @@ """Source API Views""" from django.http.response import Http404 from django.utils.text import slugify +from django_filters.filters import AllValuesMultipleFilter +from django_filters.filterset import FilterSet from drf_spectacular.utils import OpenApiResponse, extend_schema from rest_framework.decorators import action from rest_framework.request import Request @@ -101,10 +103,20 @@ class LDAPPropertyMappingSerializer(PropertyMappingSerializer): ] +class LDAPPropertyMappingFilter(FilterSet): + """Filter for LDAPPropertyMapping""" + + managed = AllValuesMultipleFilter(field_name="managed") + + class Meta: + model = LDAPPropertyMapping + fields = "__all__" + + class LDAPPropertyMappingViewSet(UsedByMixin, ModelViewSet): """LDAP PropertyMapping Viewset""" queryset = LDAPPropertyMapping.objects.all() serializer_class = LDAPPropertyMappingSerializer - filterset_fields = "__all__" + filterset_class = LDAPPropertyMappingFilter ordering = ["name"] diff --git a/schema.yml b/schema.yml index 7231c45cc..f3be16972 100644 --- a/schema.yml +++ b/schema.yml @@ -9874,7 +9874,17 @@ paths: - in: query name: managed schema: - type: string + type: array + items: + type: string + nullable: true + title: Managed by authentik + description: Objects which are managed by authentik. These objects are created + and updated automatically. This is flag only indicates that an object can + be overwritten by migrations. You can still modify the objects via the API, + but expect changes to be overwritten in a later update. + explode: true + style: form - in: query name: name schema: @@ -10133,7 +10143,17 @@ paths: - in: query name: managed schema: - type: string + type: array + items: + type: string + nullable: true + title: Managed by authentik + description: Objects which are managed by authentik. These objects are created + and updated automatically. This is flag only indicates that an object can + be overwritten by migrations. You can still modify the objects via the API, + but expect changes to be overwritten in a later update. + explode: true + style: form - in: query name: name schema: @@ -10384,7 +10404,17 @@ paths: - in: query name: managed schema: - type: string + type: array + items: + type: string + nullable: true + title: Managed by authentik + description: Objects which are managed by authentik. These objects are created + and updated automatically. This is flag only indicates that an object can + be overwritten by migrations. You can still modify the objects via the API, + but expect changes to be overwritten in a later update. + explode: true + style: form - in: query name: name schema: