From 2df4322ecf24c16fbf60b15ee8d87071e27d2a91 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Wed, 20 Oct 2021 00:11:10 +0200 Subject: [PATCH] sources/oauth: add choices to oauth provider_type Signed-off-by: Jens Langhammer --- authentik/sources/oauth/api/source.py | 3 ++- schema.yml | 21 +++++++++++++++------ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/authentik/sources/oauth/api/source.py b/authentik/sources/oauth/api/source.py index 359b2cdea..db2e38384 100644 --- a/authentik/sources/oauth/api/source.py +++ b/authentik/sources/oauth/api/source.py @@ -3,7 +3,7 @@ from django.urls.base import reverse_lazy from drf_spectacular.types import OpenApiTypes from drf_spectacular.utils import OpenApiParameter, extend_schema, extend_schema_field from rest_framework.decorators import action -from rest_framework.fields import BooleanField, CharField, SerializerMethodField +from rest_framework.fields import BooleanField, CharField, ChoiceField, SerializerMethodField from rest_framework.request import Request from rest_framework.response import Response from rest_framework.serializers import ValidationError @@ -31,6 +31,7 @@ class SourceTypeSerializer(PassiveSerializer): class OAuthSourceSerializer(SourceSerializer): """OAuth Source Serializer""" + provider_type = ChoiceField(choices=MANAGER.get_name_tuple()) callback_url = SerializerMethodField() def get_callback_url(self, instance: OAuthSource) -> str: diff --git a/schema.yml b/schema.yml index a583d5296..1c72e4b57 100644 --- a/schema.yml +++ b/schema.yml @@ -22668,8 +22668,7 @@ components: description: How the source determines if an existing user should be authenticated or a new user enrolled. provider_type: - type: string - maxLength: 255 + $ref: '#/components/schemas/ProviderTypeEnum' request_token_url: type: string nullable: true @@ -22743,8 +22742,7 @@ components: description: How the source determines if an existing user should be authenticated or a new user enrolled. provider_type: - type: string - maxLength: 255 + $ref: '#/components/schemas/ProviderTypeEnum' request_token_url: type: string nullable: true @@ -26806,8 +26804,7 @@ components: description: How the source determines if an existing user should be authenticated or a new user enrolled. provider_type: - type: string - maxLength: 255 + $ref: '#/components/schemas/ProviderTypeEnum' request_token_url: type: string nullable: true @@ -28209,6 +28206,18 @@ components: required: - authorization_flow - name + ProviderTypeEnum: + enum: + - apple + - azuread + - discord + - facebook + - github + - google + - openidconnect + - reddit + - twitter + type: string ProxyMode: enum: - proxy