Skip to content

Commit

Permalink
fixup! feat: Two Factor API
Browse files Browse the repository at this point in the history
Signed-off-by: SebastianKrupinski <[email protected]>
  • Loading branch information
SebastianKrupinski committed Jan 15, 2025
1 parent 900130c commit 68f0716
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 31 deletions.
12 changes: 7 additions & 5 deletions core/Controller/TwoFactorApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,21 @@ public function __construct(
/**
* Get two factor authentication provider states
*
* @param list<string> $users collection of system user ids
* @param string $user system user id
*
* @return DataResponse<Http::STATUS_OK, array<string, array<string, bool>>, array{}>
* @return DataResponse<Http::STATUS_OK, array<string, bool>, array{}>|DataResponse<Http::STATUS_NOT_FOUND, null, array{}>
*
* 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);
}

/**
Expand Down
68 changes: 42 additions & 26 deletions core/openapi-full.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -9565,7 +9554,7 @@
],
"responses": {
"200": {
"description": "user/provider states",
"description": "provider states",
"content": {
"application/json": {
"schema": {
Expand All @@ -9587,10 +9576,7 @@
"data": {
"type": "object",
"additionalProperties": {
"type": "object",
"additionalProperties": {
"type": "boolean"
}
"type": "boolean"
}
}
}
Expand All @@ -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
}
}
}
}
}
}
}
}
}
}
Expand Down

0 comments on commit 68f0716

Please sign in to comment.