From 68f0716b195427fdc0ab18a7894a819567a251da Mon Sep 17 00:00:00 2001 From: SebastianKrupinski Date: Wed, 15 Jan 2025 15:27:11 -0500 Subject: [PATCH] fixup! feat: Two Factor API Signed-off-by: SebastianKrupinski --- core/Controller/TwoFactorApiController.php | 12 ++-- core/openapi-full.json | 68 +++++++++++++--------- 2 files changed, 49 insertions(+), 31 deletions(-) diff --git a/core/Controller/TwoFactorApiController.php b/core/Controller/TwoFactorApiController.php index ff5db58e66a3e..8e55253808314 100644 --- a/core/Controller/TwoFactorApiController.php +++ b/core/Controller/TwoFactorApiController.php @@ -30,19 +30,21 @@ public function __construct( /** * Get two factor authentication provider states * - * @param list $users collection of system user ids + * @param string $user system user id * - * @return DataResponse>, array{}> + * @return DataResponse, array{}>|DataResponse * - * 200: user/provider states + * 200: provider states + * 404: user not found */ #[ApiRoute(verb: 'GET', url: '/state', root: '/twofactor')] public function state(string $user): DataResponse { $userObject = $this->userManager->get($user); if ($userObject !== null) { - $states = $this->tfRegistry->getProviderStates($userObject); + $state = $this->tfRegistry->getProviderStates($userObject); + return new DataResponse($state); } - return new DataResponse($states); + return new DataResponse(null, Http::STATUS_NOT_FOUND); } /** diff --git a/core/openapi-full.json b/core/openapi-full.json index 30376efe86c81..4fa69b0a031e8 100644 --- a/core/openapi-full.json +++ b/core/openapi-full.json @@ -9516,7 +9516,7 @@ } }, "/ocs/v2.php/twofactor/state": { - "post": { + "get": { "operationId": "two_factor_api-state", "summary": "Get two factor authentication provider states", "description": "This endpoint requires admin access", @@ -9531,27 +9531,16 @@ "basic_auth": [] } ], - "requestBody": { - "required": false, - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "users": { - "type": "array", - "default": [], - "description": "collection of system user ids", - "items": { - "type": "string" - } - } - } - } - } - } - }, "parameters": [ + { + "name": "user", + "in": "query", + "description": "system user id", + "required": true, + "schema": { + "type": "string" + } + }, { "name": "OCS-APIRequest", "in": "header", @@ -9565,7 +9554,7 @@ ], "responses": { "200": { - "description": "user/provider states", + "description": "provider states", "content": { "application/json": { "schema": { @@ -9587,10 +9576,7 @@ "data": { "type": "object", "additionalProperties": { - "type": "object", - "additionalProperties": { - "type": "boolean" - } + "type": "boolean" } } } @@ -9599,6 +9585,36 @@ } } } + }, + "404": { + "description": "user not found", + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "ocs" + ], + "properties": { + "ocs": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "meta": { + "$ref": "#/components/schemas/OCSMeta" + }, + "data": { + "nullable": true + } + } + } + } + } + } + } } } }