sources/oauth: add choices to oauth provider_type

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-10-20 00:11:10 +02:00
parent bb8e0c6f59
commit 2df4322ecf
2 changed files with 17 additions and 7 deletions

View file

@ -3,7 +3,7 @@ from django.urls.base import reverse_lazy
from drf_spectacular.types import OpenApiTypes from drf_spectacular.types import OpenApiTypes
from drf_spectacular.utils import OpenApiParameter, extend_schema, extend_schema_field from drf_spectacular.utils import OpenApiParameter, extend_schema, extend_schema_field
from rest_framework.decorators import action 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.request import Request
from rest_framework.response import Response from rest_framework.response import Response
from rest_framework.serializers import ValidationError from rest_framework.serializers import ValidationError
@ -31,6 +31,7 @@ class SourceTypeSerializer(PassiveSerializer):
class OAuthSourceSerializer(SourceSerializer): class OAuthSourceSerializer(SourceSerializer):
"""OAuth Source Serializer""" """OAuth Source Serializer"""
provider_type = ChoiceField(choices=MANAGER.get_name_tuple())
callback_url = SerializerMethodField() callback_url = SerializerMethodField()
def get_callback_url(self, instance: OAuthSource) -> str: def get_callback_url(self, instance: OAuthSource) -> str:

View file

@ -22668,8 +22668,7 @@ components:
description: How the source determines if an existing user should be authenticated description: How the source determines if an existing user should be authenticated
or a new user enrolled. or a new user enrolled.
provider_type: provider_type:
type: string $ref: '#/components/schemas/ProviderTypeEnum'
maxLength: 255
request_token_url: request_token_url:
type: string type: string
nullable: true nullable: true
@ -22743,8 +22742,7 @@ components:
description: How the source determines if an existing user should be authenticated description: How the source determines if an existing user should be authenticated
or a new user enrolled. or a new user enrolled.
provider_type: provider_type:
type: string $ref: '#/components/schemas/ProviderTypeEnum'
maxLength: 255
request_token_url: request_token_url:
type: string type: string
nullable: true nullable: true
@ -26806,8 +26804,7 @@ components:
description: How the source determines if an existing user should be authenticated description: How the source determines if an existing user should be authenticated
or a new user enrolled. or a new user enrolled.
provider_type: provider_type:
type: string $ref: '#/components/schemas/ProviderTypeEnum'
maxLength: 255
request_token_url: request_token_url:
type: string type: string
nullable: true nullable: true
@ -28209,6 +28206,18 @@ components:
required: required:
- authorization_flow - authorization_flow
- name - name
ProviderTypeEnum:
enum:
- apple
- azuread
- discord
- facebook
- github
- google
- openidconnect
- reddit
- twitter
type: string
ProxyMode: ProxyMode:
enum: enum:
- proxy - proxy