From b35b2254531b06ca0f9aeb50fbfa1c3ccfa67323 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sun, 11 Sep 2022 23:01:59 +0200 Subject: [PATCH] flows: always mark component field as required in Challenge and ChallengeResponses Signed-off-by: Jens Langhammer --- authentik/flows/challenge.py | 5 ++++ schema.yml | 46 ++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/authentik/flows/challenge.py b/authentik/flows/challenge.py index 15cea8b92..86d52af18 100644 --- a/authentik/flows/challenge.py +++ b/authentik/flows/challenge.py @@ -68,6 +68,10 @@ class Challenge(PassiveSerializer): child=ErrorDetailSerializer(many=True), allow_empty=True, required=False ) + def __init__(self, instance=None, data=..., **kwargs): + super().__init__(instance, data, **kwargs) + self.fields["component"].required = True + class RedirectChallenge(Challenge): """Challenge type to redirect the client""" @@ -148,6 +152,7 @@ class ChallengeResponse(PassiveSerializer): def __init__(self, instance=None, data=None, **kwargs): self.stage = kwargs.pop("stage", None) super().__init__(instance=instance, data=data, **kwargs) + self.fields["component"].required = True class AutosubmitChallenge(Challenge): diff --git a/schema.yml b/schema.yml index b90de7dac..2e3167ee8 100644 --- a/schema.yml +++ b/schema.yml @@ -24512,6 +24512,7 @@ components: error_message: type: string required: + - component - pending_user - pending_user_avatar - type @@ -24583,6 +24584,8 @@ components: type: string minLength: 1 default: ak-flow-sources-oauth-apple + required: + - component AppleLoginChallenge: type: object description: Special challenge for apple-native authentication flow, which happens @@ -24611,6 +24614,7 @@ components: type: string required: - client_id + - component - redirect_uri - scope - state @@ -24934,6 +24938,7 @@ components: required: - activation_barcode - activation_code + - component - pending_user - pending_user_avatar - stage_uuid @@ -24946,6 +24951,8 @@ components: type: string minLength: 1 default: ak-stage-authenticator-duo + required: + - component AuthenticatorDuoStage: type: object description: AuthenticatorDuoStage Serializer @@ -25049,6 +25056,7 @@ components: type: boolean default: true required: + - component - pending_user - pending_user_avatar - type @@ -25065,6 +25073,8 @@ components: phone_number: type: string minLength: 1 + required: + - component AuthenticatorSMSStage: type: object description: AuthenticatorSMSStage Serializer @@ -25196,6 +25206,7 @@ components: type: string required: - codes + - component - pending_user - pending_user_avatar - type @@ -25207,6 +25218,8 @@ components: type: string minLength: 1 default: ak-stage-authenticator-static + required: + - component AuthenticatorStaticStage: type: object description: AuthenticatorStaticStage Serializer @@ -25298,6 +25311,7 @@ components: config_url: type: string required: + - component - config_url - pending_user - pending_user_avatar @@ -25314,6 +25328,7 @@ components: type: integer required: - code + - component AuthenticatorTOTPStage: type: object description: AuthenticatorTOTPStage Serializer @@ -25501,6 +25516,7 @@ components: items: $ref: '#/components/schemas/SelectableStage' required: + - component - configuration_stages - device_challenges - pending_user @@ -25527,6 +25543,8 @@ components: additionalProperties: {} duo: type: integer + required: + - component AuthenticatorWebAuthnChallenge: type: object description: WebAuthn Challenge @@ -25552,6 +25570,7 @@ components: type: object additionalProperties: {} required: + - component - pending_user - pending_user_avatar - registration @@ -25568,6 +25587,7 @@ components: type: object additionalProperties: {} required: + - component - response AutoSubmitChallengeResponseRequest: type: object @@ -25577,6 +25597,8 @@ components: type: string minLength: 1 default: ak-stage-autosubmit + required: + - component AutosubmitChallenge: type: object description: Autosubmit challenge used to send and navigate a POST request @@ -25604,6 +25626,7 @@ components: type: string required: - attrs + - component - type - url BackendsEnum: @@ -25749,6 +25772,7 @@ components: site_key: type: string required: + - component - pending_user - pending_user_avatar - site_key @@ -25765,6 +25789,7 @@ components: type: string minLength: 1 required: + - component - token CaptchaStage: type: object @@ -26052,6 +26077,7 @@ components: type: string required: - additional_permissions + - component - pending_user - pending_user_avatar - permissions @@ -26069,6 +26095,7 @@ components: type: string minLength: 1 required: + - component - token ConsentStage: type: object @@ -26439,6 +26466,7 @@ components: items: $ref: '#/components/schemas/ErrorDetail' required: + - component - type DummyChallengeResponseRequest: type: object @@ -26448,6 +26476,8 @@ components: type: string minLength: 1 default: ak-stage-dummy + required: + - component DummyPolicy: type: object description: Dummy Policy Serializer @@ -26621,6 +26651,7 @@ components: items: $ref: '#/components/schemas/ErrorDetail' required: + - component - type EmailChallengeResponseRequest: type: object @@ -26632,6 +26663,8 @@ components: type: string minLength: 1 default: ak-stage-email + required: + - component EmailStage: type: object description: EmailStage Serializer @@ -27242,6 +27275,7 @@ components: traceback: type: string required: + - component - pending_user - pending_user_avatar - request_id @@ -27687,6 +27721,7 @@ components: show_source_labels: type: boolean required: + - component - password_fields - primary_action - show_source_labels @@ -27707,6 +27742,7 @@ components: type: string nullable: true required: + - component - uid_field IdentificationStage: type: object @@ -32161,6 +32197,7 @@ components: recovery_url: type: string required: + - component - pending_user - pending_user_avatar - type @@ -32176,6 +32213,7 @@ components: type: string minLength: 1 required: + - component - password PasswordExpiryPolicy: type: object @@ -34323,6 +34361,7 @@ components: type: string required: - client_id + - component - slug - type PlexAuthenticationChallengeResponseRequest: @@ -34333,6 +34372,8 @@ components: type: string minLength: 1 default: ak-flow-sources-plex + required: + - component PlexSource: type: object description: Plex Source Serializer @@ -34758,6 +34799,7 @@ components: items: $ref: '#/components/schemas/StagePrompt' required: + - component - fields - type PromptChallengeResponseRequest: @@ -34770,6 +34812,8 @@ components: type: string minLength: 1 default: ak-stage-prompt + required: + - component additionalProperties: {} PromptRequest: type: object @@ -35313,6 +35357,7 @@ components: to: type: string required: + - component - to - type RefreshTokenModel: @@ -36184,6 +36229,7 @@ components: type: string required: - body + - component - type SignatureAlgorithmEnum: enum: