-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
base: master
Are you sure you want to change the base?
feat: Two Factor API #49443
Conversation
c40f0c2
to
462afd8
Compare
All the endpoints are only intended to be used by admins? |
Apologies, didn't realize I did not link the issue ticket. I've updated the description. |
462afd8
to
3e2659b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine by me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good otherwise
* | ||
* 200: user/provider states | ||
*/ | ||
#[ApiRoute(verb: 'POST', url: '/state', root: '/twofactor')] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be a GET
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey,
The reason this is a POST is because its pretty messy to send an array of user names in a GET url.
This command retrieves the states for specific users not just one user.
POST /twofactor/state
{
"users": ["admin", "user1", "user2"]
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is possible using this syntax: ?user[]=a&user[]=b
, but indeed very ugly. Not sure what is better here 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GET is the right verb here. If the arguments make the URL ugly so be it.
As an alternative you could drop the bulk operation aspect. It's not a concept I've seen with any other Nextcloud APIs. If there is only one user, like with the occ command, the URL will become "pretty" again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, if there is no need to query multiple users at once then it is much better to only implement it for a single user.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well the idea behind the bulk operation was that an external system can check the state of 2fa on a 100+ accounts at the same time instead of doing 100 requests.
But if you insist on this being a GET then having this as an array makes it ugly. I'll change it.
* | ||
* 200: user/provider states | ||
*/ | ||
#[ApiRoute(verb: 'POST', url: '/state', root: '/twofactor')] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
POST is still used here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, its because I didn't see you comments before asking for a review.
3e2659b
to
900130c
Compare
Signed-off-by: SebastianKrupinski <[email protected]>
68f0716
to
332fa63
Compare
Ability to check/enable/disable configured 2FA with API endpoint
Request State
Request Disable
Request Enable