*: make all PropertyMappings filterable by multiple managed attributes
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
16f0f89a9d
commit
ccfc1dbcc2
|
@ -1,4 +1,6 @@
|
||||||
"""OAuth2Provider API Views"""
|
"""OAuth2Provider API Views"""
|
||||||
|
from django_filters.filters import AllValuesMultipleFilter
|
||||||
|
from django_filters.filterset import FilterSet
|
||||||
from rest_framework.viewsets import ModelViewSet
|
from rest_framework.viewsets import ModelViewSet
|
||||||
|
|
||||||
from authentik.core.api.propertymappings import PropertyMappingSerializer
|
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):
|
class ScopeMappingViewSet(UsedByMixin, ModelViewSet):
|
||||||
"""ScopeMapping Viewset"""
|
"""ScopeMapping Viewset"""
|
||||||
|
|
||||||
queryset = ScopeMapping.objects.all()
|
queryset = ScopeMapping.objects.all()
|
||||||
serializer_class = ScopeMappingSerializer
|
serializer_class = ScopeMappingSerializer
|
||||||
filterset_fields = ["scope_name", "name", "managed"]
|
filterset_class = ScopeMappingFilter
|
||||||
ordering = ["scope_name", "name"]
|
ordering = ["scope_name", "name"]
|
||||||
|
|
|
@ -6,6 +6,8 @@ from django.http.response import Http404, HttpResponse
|
||||||
from django.shortcuts import get_object_or_404
|
from django.shortcuts import get_object_or_404
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.utils.translation import gettext_lazy as _
|
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.types import OpenApiTypes
|
||||||
from drf_spectacular.utils import OpenApiParameter, OpenApiResponse, extend_schema
|
from drf_spectacular.utils import OpenApiParameter, OpenApiResponse, extend_schema
|
||||||
from rest_framework.decorators import action
|
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):
|
class SAMLPropertyMappingViewSet(UsedByMixin, ModelViewSet):
|
||||||
"""SAMLPropertyMapping Viewset"""
|
"""SAMLPropertyMapping Viewset"""
|
||||||
|
|
||||||
queryset = SAMLPropertyMapping.objects.all()
|
queryset = SAMLPropertyMapping.objects.all()
|
||||||
serializer_class = SAMLPropertyMappingSerializer
|
serializer_class = SAMLPropertyMappingSerializer
|
||||||
filterset_fields = "__all__"
|
filterset_class = SAMLPropertyMappingFilter
|
||||||
ordering = ["name"]
|
ordering = ["name"]
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
"""Source API Views"""
|
"""Source API Views"""
|
||||||
from django.http.response import Http404
|
from django.http.response import Http404
|
||||||
from django.utils.text import slugify
|
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 drf_spectacular.utils import OpenApiResponse, extend_schema
|
||||||
from rest_framework.decorators import action
|
from rest_framework.decorators import action
|
||||||
from rest_framework.request import Request
|
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):
|
class LDAPPropertyMappingViewSet(UsedByMixin, ModelViewSet):
|
||||||
"""LDAP PropertyMapping Viewset"""
|
"""LDAP PropertyMapping Viewset"""
|
||||||
|
|
||||||
queryset = LDAPPropertyMapping.objects.all()
|
queryset = LDAPPropertyMapping.objects.all()
|
||||||
serializer_class = LDAPPropertyMappingSerializer
|
serializer_class = LDAPPropertyMappingSerializer
|
||||||
filterset_fields = "__all__"
|
filterset_class = LDAPPropertyMappingFilter
|
||||||
ordering = ["name"]
|
ordering = ["name"]
|
||||||
|
|
30
schema.yml
30
schema.yml
|
@ -9874,7 +9874,17 @@ paths:
|
||||||
- in: query
|
- in: query
|
||||||
name: managed
|
name: managed
|
||||||
schema:
|
schema:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
type: string
|
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
|
- in: query
|
||||||
name: name
|
name: name
|
||||||
schema:
|
schema:
|
||||||
|
@ -10133,7 +10143,17 @@ paths:
|
||||||
- in: query
|
- in: query
|
||||||
name: managed
|
name: managed
|
||||||
schema:
|
schema:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
type: string
|
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
|
- in: query
|
||||||
name: name
|
name: name
|
||||||
schema:
|
schema:
|
||||||
|
@ -10384,7 +10404,17 @@ paths:
|
||||||
- in: query
|
- in: query
|
||||||
name: managed
|
name: managed
|
||||||
schema:
|
schema:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
type: string
|
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
|
- in: query
|
||||||
name: name
|
name: name
|
||||||
schema:
|
schema:
|
||||||
|
|
Reference in New Issue