Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Two Factor API #49443

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft

Conversation

SebastianKrupinski
Copy link
Contributor

@SebastianKrupinski SebastianKrupinski commented Nov 23, 2024

Ability to check/enable/disable configured 2FA with API endpoint

Request State

POST /twofactor/state

{
	"users": ["admin", "user1", "user2"]
}

Request Disable

POST /twofactor/disable

{
  "user": "user1",
  "providers": [
    "backup_codes",
    "totp"
  ]
}

Request Enable

POST /twofactor/enable

{
  "user": "user2",
  "providers": [
    "backup_codes",
    "totp"
  ]
}

Signed-off-by: SebastianKrupinski <[email protected]>
@SebastianKrupinski SebastianKrupinski added the 2. developing Work in progress label Nov 23, 2024
@SebastianKrupinski SebastianKrupinski self-assigned this Nov 23, 2024
@SebastianKrupinski SebastianKrupinski marked this pull request as draft November 23, 2024 00:12
*
* @param list<string> $users collection of system user ids
*
* @return DataResponse<Http::STATUS_OK, list{string: list{string: bool}}, array{}>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @return DataResponse<Http::STATUS_OK, list{string: list{string: bool}}, array{}>
* @return DataResponse<Http::STATUS_OK, array<string, array<string, bool>>, array{}>

$state = $this->tfRegistry->getProviderStates($userObject);
return new DataResponse($state);
}
return new DataResponse([], Http::STATUS_NOT_FOUND);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return empty list is illegal 😿

Suggested change
return new DataResponse([], Http::STATUS_NOT_FOUND);
return new DataResponse(null, Http::STATUS_NOT_FOUND);

* @param string $user system user identifier
* @param list<string> $providers collection of TFA provider ids
*
* @return DataResponse<Http::STATUS_OK|Http::STATUS_NOT_FOUND, list{string: bool}, array{}>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @return DataResponse<Http::STATUS_OK|Http::STATUS_NOT_FOUND, list{string: bool}, array{}>
* @return DataResponse<Http::STATUS_O, array<string, bool>, array{}>|DataResponse<Http::STATUS_NOT_FOUND, null, array{}>

Signed-off-by: SebastianKrupinski <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2. developing Work in progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants