core: add additional filters to source viewset

https://github.com/goauthentik/terraform-provider-authentik/issues/184
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2022-06-05 00:56:46 +02:00
parent 210775776f
commit 817d538b8f
2 changed files with 66 additions and 1 deletions

View File

@ -8,7 +8,7 @@ from rest_framework.decorators import action
from rest_framework.filters import OrderingFilter, SearchFilter
from rest_framework.request import Request
from rest_framework.response import Response
from rest_framework.serializers import ModelSerializer, SerializerMethodField
from rest_framework.serializers import ModelSerializer, SerializerMethodField, ReadOnlyField
from rest_framework.viewsets import GenericViewSet
from structlog.stdlib import get_logger
@ -26,6 +26,7 @@ LOGGER = get_logger()
class SourceSerializer(ModelSerializer, MetaNameSerializer):
"""Source Serializer"""
managed = ReadOnlyField()
component = SerializerMethodField()
def get_component(self, obj: Source) -> str:
@ -51,6 +52,7 @@ class SourceSerializer(ModelSerializer, MetaNameSerializer):
"meta_model_name",
"policy_engine_mode",
"user_matching_mode",
"managed",
]
@ -67,6 +69,7 @@ class SourceViewSet(
serializer_class = SourceSerializer
lookup_field = "slug"
search_fields = ["slug", "name"]
filterset_fields = ["slug", "name", "managed"]
def get_queryset(self): # pragma: no cover
return Source.objects.select_subclasses()

View File

@ -11862,6 +11862,14 @@ paths:
operationId: sources_all_list
description: Source Viewset
parameters:
- in: query
name: managed
schema:
type: string
- in: query
name: name
schema:
type: string
- name: ordering
required: false
in: query
@ -11886,6 +11894,10 @@ paths:
description: A search term.
schema:
type: string
- in: query
name: slug
schema:
type: string
tags:
- sources
security:
@ -22678,6 +22690,15 @@ components:
- $ref: '#/components/schemas/UserMatchingModeEnum'
description: How the source determines if an existing user should be authenticated
or a new user enrolled.
managed:
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.
readOnly: true
server_uri:
type: string
format: uri
@ -22740,6 +22761,7 @@ components:
required:
- base_dn
- component
- managed
- meta_model_name
- name
- pk
@ -23394,6 +23416,15 @@ components:
- $ref: '#/components/schemas/UserMatchingModeEnum'
description: How the source determines if an existing user should be authenticated
or a new user enrolled.
managed:
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.
readOnly: true
provider_type:
$ref: '#/components/schemas/ProviderTypeEnum'
request_token_url:
@ -23439,6 +23470,7 @@ components:
- callback_url
- component
- consumer_key
- managed
- meta_model_name
- name
- pk
@ -28620,6 +28652,15 @@ components:
- $ref: '#/components/schemas/UserMatchingModeEnum'
description: How the source determines if an existing user should be authenticated
or a new user enrolled.
managed:
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.
readOnly: true
client_id:
type: string
description: Client identifier used to talk to Plex.
@ -28637,6 +28678,7 @@ components:
description: Plex token used to check friends
required:
- component
- managed
- meta_model_name
- name
- pk
@ -30011,6 +30053,15 @@ components:
- $ref: '#/components/schemas/UserMatchingModeEnum'
description: How the source determines if an existing user should be authenticated
or a new user enrolled.
managed:
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.
readOnly: true
pre_authentication_flow:
type: string
format: uuid
@ -30059,6 +30110,7 @@ components:
doesn''t log out manually. (Format: hours=1;minutes=2;seconds=3).'
required:
- component
- managed
- meta_model_name
- name
- pk
@ -30437,8 +30489,18 @@ components:
- $ref: '#/components/schemas/UserMatchingModeEnum'
description: How the source determines if an existing user should be authenticated
or a new user enrolled.
managed:
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.
readOnly: true
required:
- component
- managed
- meta_model_name
- name
- pk