core: mark provider_obj as read_only

closes #2637

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2022-04-04 10:17:59 +02:00
parent dea61ef35e
commit 20262f3f4b
3 changed files with 10 additions and 12 deletions

View File

@ -44,7 +44,7 @@ class ApplicationSerializer(ModelSerializer):
"""Application Serializer""" """Application Serializer"""
launch_url = SerializerMethodField() launch_url = SerializerMethodField()
provider_obj = ProviderSerializer(source="get_provider", required=False) provider_obj = ProviderSerializer(source="get_provider", required=False, read_only=True)
meta_icon = ReadOnlyField(source="get_meta_icon") meta_icon = ReadOnlyField(source="get_meta_icon")

View File

@ -26,7 +26,7 @@ from authentik.managed.api import ManagedSerializer
class TokenSerializer(ManagedSerializer, ModelSerializer): class TokenSerializer(ManagedSerializer, ModelSerializer):
"""Token Serializer""" """Token Serializer"""
user_obj = UserSerializer(required=False, source="user") user_obj = UserSerializer(required=False, source="user", read_only=True)
def validate(self, attrs: dict[Any, str]) -> dict[Any, str]: def validate(self, attrs: dict[Any, str]) -> dict[Any, str]:
"""Ensure only API or App password tokens are created.""" """Ensure only API or App password tokens are created."""

View File

@ -19090,7 +19090,9 @@ components:
type: integer type: integer
nullable: true nullable: true
provider_obj: provider_obj:
$ref: '#/components/schemas/Provider' allOf:
- $ref: '#/components/schemas/Provider'
readOnly: true
launch_url: launch_url:
type: string type: string
nullable: true nullable: true
@ -19115,6 +19117,7 @@ components:
- meta_icon - meta_icon
- name - name
- pk - pk
- provider_obj
- slug - slug
ApplicationRequest: ApplicationRequest:
type: object type: object
@ -19133,8 +19136,6 @@ components:
provider: provider:
type: integer type: integer
nullable: true nullable: true
provider_obj:
$ref: '#/components/schemas/ProviderRequest'
meta_launch_url: meta_launch_url:
type: string type: string
format: uri format: uri
@ -26591,8 +26592,6 @@ components:
provider: provider:
type: integer type: integer
nullable: true nullable: true
provider_obj:
$ref: '#/components/schemas/ProviderRequest'
meta_launch_url: meta_launch_url:
type: string type: string
format: uri format: uri
@ -28252,8 +28251,6 @@ components:
$ref: '#/components/schemas/IntentEnum' $ref: '#/components/schemas/IntentEnum'
user: user:
type: integer type: integer
user_obj:
$ref: '#/components/schemas/UserRequest'
description: description:
type: string type: string
expires: expires:
@ -30756,7 +30753,9 @@ components:
user: user:
type: integer type: integer
user_obj: user_obj:
$ref: '#/components/schemas/User' allOf:
- $ref: '#/components/schemas/User'
readOnly: true
description: description:
type: string type: string
expires: expires:
@ -30767,6 +30766,7 @@ components:
required: required:
- identifier - identifier
- pk - pk
- user_obj
TokenRequest: TokenRequest:
type: object type: object
description: Token Serializer description: Token Serializer
@ -30789,8 +30789,6 @@ components:
$ref: '#/components/schemas/IntentEnum' $ref: '#/components/schemas/IntentEnum'
user: user:
type: integer type: integer
user_obj:
$ref: '#/components/schemas/UserRequest'
description: description:
type: string type: string
expires: expires: