From b5e059dfd9ce928dd4f6a0b8ab18c9bf3a0c0b48 Mon Sep 17 00:00:00 2001 From: Jens L Date: Fri, 17 Nov 2023 00:07:21 +0100 Subject: [PATCH] root: fix API schema for kotlin (#7601) Signed-off-by: Jens Langhammer --- authentik/admin/api/system.py | 12 +++---- authentik/stages/authenticator_totp/models.py | 2 +- blueprints/schema.json | 6 ++-- schema.yml | 33 +++++++------------ .../admin-overview/cards/SystemStatusCard.ts | 8 ++--- .../AuthenticatorTOTPStageForm.ts | 8 ++--- web/xliff/de.xlf | 3 ++ web/xliff/en.xlf | 3 ++ web/xliff/es.xlf | 3 ++ web/xliff/fr.xlf | 3 ++ web/xliff/pl.xlf | 3 ++ web/xliff/pseudo-LOCALE.xlf | 3 ++ web/xliff/tr.xlf | 3 ++ web/xliff/zh-Hans.xlf | 3 ++ web/xliff/zh-Hant.xlf | 3 ++ web/xliff/zh_TW.xlf | 3 ++ 16 files changed, 60 insertions(+), 39 deletions(-) diff --git a/authentik/admin/api/system.py b/authentik/admin/api/system.py index 7e7d2d920..5a7007153 100644 --- a/authentik/admin/api/system.py +++ b/authentik/admin/api/system.py @@ -30,7 +30,7 @@ class RuntimeDict(TypedDict): uname: str -class SystemSerializer(PassiveSerializer): +class SystemInfoSerializer(PassiveSerializer): """Get system information.""" http_headers = SerializerMethodField() @@ -91,14 +91,14 @@ class SystemView(APIView): permission_classes = [HasPermission("authentik_rbac.view_system_info")] pagination_class = None filter_backends = [] - serializer_class = SystemSerializer + serializer_class = SystemInfoSerializer - @extend_schema(responses={200: SystemSerializer(many=False)}) + @extend_schema(responses={200: SystemInfoSerializer(many=False)}) def get(self, request: Request) -> Response: """Get system information.""" - return Response(SystemSerializer(request).data) + return Response(SystemInfoSerializer(request).data) - @extend_schema(responses={200: SystemSerializer(many=False)}) + @extend_schema(responses={200: SystemInfoSerializer(many=False)}) def post(self, request: Request) -> Response: """Get system information.""" - return Response(SystemSerializer(request).data) + return Response(SystemInfoSerializer(request).data) diff --git a/authentik/stages/authenticator_totp/models.py b/authentik/stages/authenticator_totp/models.py index 41bf2d2c8..e00d39d40 100644 --- a/authentik/stages/authenticator_totp/models.py +++ b/authentik/stages/authenticator_totp/models.py @@ -19,7 +19,7 @@ from authentik.stages.authenticator.oath import TOTP from authentik.stages.authenticator.util import hex_validator, random_hex -class TOTPDigits(models.IntegerChoices): +class TOTPDigits(models.TextChoices): """OTP Time Digits""" SIX = 6, _("6 digits, widely compatible") diff --git a/blueprints/schema.json b/blueprints/schema.json index 6fe11e20a..bab793b70 100644 --- a/blueprints/schema.json +++ b/blueprints/schema.json @@ -6241,10 +6241,10 @@ "title": "Friendly name" }, "digits": { - "type": "integer", + "type": "string", "enum": [ - 6, - 8 + "6", + "8" ], "title": "Digits" } diff --git a/schema.yml b/schema.yml index fd025466a..d7c59dfec 100644 --- a/schema.yml +++ b/schema.yml @@ -107,7 +107,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/System' + $ref: '#/components/schemas/SystemInfo' description: '' '400': content: @@ -133,7 +133,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/System' + $ref: '#/components/schemas/SystemInfo' description: '' '400': content: @@ -22451,10 +22451,10 @@ paths: - in: query name: digits schema: - type: integer + type: string enum: - - 6 - - 8 + - '6' + - '8' description: |- * `6` - 6 digits, widely compatible * `8` - 8 digits, not compatible with apps like Google Authenticator @@ -28794,10 +28794,7 @@ components: type: string nullable: true digits: - allOf: - - $ref: '#/components/schemas/DigitsEnum' - minimum: -2147483648 - maximum: 2147483647 + $ref: '#/components/schemas/DigitsEnum' required: - component - digits @@ -28828,10 +28825,7 @@ components: nullable: true minLength: 1 digits: - allOf: - - $ref: '#/components/schemas/DigitsEnum' - minimum: -2147483648 - maximum: 2147483647 + $ref: '#/components/schemas/DigitsEnum' required: - digits - name @@ -29920,9 +29914,9 @@ components: * `http://www.w3.org/2001/04/xmlenc#sha512` - SHA512 DigitsEnum: enum: - - 6 - - 8 - type: integer + - '6' + - '8' + type: string description: |- * `6` - 6 digits, widely compatible * `8` - 8 digits, not compatible with apps like Google Authenticator @@ -35909,10 +35903,7 @@ components: nullable: true minLength: 1 digits: - allOf: - - $ref: '#/components/schemas/DigitsEnum' - minimum: -2147483648 - maximum: 2147483647 + $ref: '#/components/schemas/DigitsEnum' PatchedAuthenticatorValidateStageRequest: type: object description: AuthenticatorValidateStage Serializer @@ -41152,7 +41143,7 @@ components: * `user_username` - Based on the username * `user_email` - Based on the User's Email. This is recommended over the UPN method. * `user_upn` - Based on the User's UPN, only works if user has a 'upn' attribute set. Use this method only if you have different UPN and Mail domains. - System: + SystemInfo: type: object description: Get system information. properties: diff --git a/web/src/admin/admin-overview/cards/SystemStatusCard.ts b/web/src/admin/admin-overview/cards/SystemStatusCard.ts index eee0bca32..7c6ac276c 100644 --- a/web/src/admin/admin-overview/cards/SystemStatusCard.ts +++ b/web/src/admin/admin-overview/cards/SystemStatusCard.ts @@ -8,10 +8,10 @@ import { msg } from "@lit/localize"; import { TemplateResult, html } from "lit"; import { customElement, state } from "lit/decorators.js"; -import { AdminApi, OutpostsApi, System } from "@goauthentik/api"; +import { AdminApi, OutpostsApi, SystemInfo } from "@goauthentik/api"; @customElement("ak-admin-status-system") -export class SystemStatusCard extends AdminStatusCard { +export class SystemStatusCard extends AdminStatusCard { now?: Date; icon = "pf-icon pf-icon-server"; @@ -19,7 +19,7 @@ export class SystemStatusCard extends AdminStatusCard { @state() statusSummary?: string; - async getPrimaryValue(): Promise { + async getPrimaryValue(): Promise { this.now = new Date(); let status = await new AdminApi(DEFAULT_CONFIG).adminSystemRetrieve(); if (status.embeddedOutpostHost === "" || !status.embeddedOutpostHost.includes("http")) { @@ -50,7 +50,7 @@ export class SystemStatusCard extends AdminStatusCard { }); } - getStatus(value: System): Promise { + getStatus(value: SystemInfo): Promise { if (value.embeddedOutpostHost === "") { this.statusSummary = msg("Warning"); return Promise.resolve({ diff --git a/web/src/admin/stages/authenticator_totp/AuthenticatorTOTPStageForm.ts b/web/src/admin/stages/authenticator_totp/AuthenticatorTOTPStageForm.ts index ff44f9349..aebca9872 100644 --- a/web/src/admin/stages/authenticator_totp/AuthenticatorTOTPStageForm.ts +++ b/web/src/admin/stages/authenticator_totp/AuthenticatorTOTPStageForm.ts @@ -89,14 +89,14 @@ export class AuthenticatorTOTPStageForm extends ModelForm