Feature | Implement Two-Factor Authentication (2FA) support for users#126
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
📘 OpenAPI / Swagger preview ➡️ https://OpenStackweb.github.io/openstackid/openapi/pr-126/ This page is automatically updated on each push to this PR. |
c3c6568 to
15f001a
Compare
|
📘 OpenAPI / Swagger preview ➡️ https://OpenStackweb.github.io/openstackid/openapi/pr-126/ This page is automatically updated on each push to this PR. |
15f001a to
561ef7c
Compare
|
📘 OpenAPI / Swagger preview ➡️ https://OpenStackweb.github.io/openstackid/openapi/pr-126/ This page is automatically updated on each push to this PR. |
561ef7c to
c081f57
Compare
|
📘 OpenAPI / Swagger preview ➡️ https://OpenStackweb.github.io/openstackid/openapi/pr-126/ This page is automatically updated on each push to this PR. |
c081f57 to
d71d733
Compare
|
📘 OpenAPI / Swagger preview ➡️ https://OpenStackweb.github.io/openstackid/openapi/pr-126/ This page is automatically updated on each push to this PR. |
d71d733 to
1d8c6e4
Compare
|
📘 OpenAPI / Swagger preview ➡️ https://OpenStackweb.github.io/openstackid/openapi/pr-126/ This page is automatically updated on each push to this PR. |
martinquiroga-exo
left a comment
There was a problem hiding this comment.
@matiasperrone-exo please see comments. Thanks.
f75c63d to
4624ff5
Compare
|
📘 OpenAPI / Swagger preview ➡️ https://OpenStackweb.github.io/openstackid/openapi/pr-126/ This page is automatically updated on each push to this PR. |
|
@martinquiroga-exo please review again |
823bfd0 to
133b2a8
Compare
|
📘 OpenAPI / Swagger preview ➡️ https://OpenStackweb.github.io/openstackid/openapi/pr-126/ This page is automatically updated on each push to this PR. |
133b2a8 to
1d8c6e4
Compare
|
📘 OpenAPI / Swagger preview ➡️ https://OpenStackweb.github.io/openstackid/openapi/pr-126/ This page is automatically updated on each push to this PR. |
1 similar comment
|
📘 OpenAPI / Swagger preview ➡️ https://OpenStackweb.github.io/openstackid/openapi/pr-126/ This page is automatically updated on each push to this PR. |
5f9b3a2 to
894cbe4
Compare
|
📘 OpenAPI / Swagger preview ➡️ https://OpenStackweb.github.io/openstackid/openapi/pr-126/ This page is automatically updated on each push to this PR. |
894cbe4 to
fc6818d
Compare
|
📘 OpenAPI / Swagger preview ➡️ https://OpenStackweb.github.io/openstackid/openapi/pr-126/ This page is automatically updated on each push to this PR. |
8fab15c to
5b8c829
Compare
a5c0cff to
f21b6fb
Compare
|
@matiasperrone-exo — small rename request to align this PR with the SDS.
No in-flight PR currently calls either spelling — PR #125 (base) and PR #127 (AuthService validateCredentials) don't reference it — so the rename is safe to make on this branch only:
The current spelling is more grammatical, but updating the SDS in lockstep is more disruptive than matching it here. |
caseylocker
left a comment
There was a problem hiding this comment.
Three more findings on top of the rename request, ordered by severity. Each is also added as a line-level comment below.
-
setTwoFactorEnabled()couples write-state to policy —app/libs/Auth/Models/User.php:2436-2438.setTwoFactorEnabled(false)silently persiststruefor users inenforced_groupsbecauseshouldRequire2FA()short-circuits before reading the flag. Both the SDS § 6 and the ticket DOD prescribe direct assignment inenable2FA()with no policy-overlaying setter. -
Dead validation tier in
setTwoFactorMethod()—app/libs/Auth/Models/User.php:2449-2473. The innerValidMFAMethodscheck is unreachable from public callers; only the reflection test exercises it. Both the SDS and the ticket prescribe single-tier validation inenable2FA()with nosetTwoFactorMethod()setter at all. -
Unrelated change in
SocialLoginController.php:160— error message wording shortened. Out of scope by the ticket's own statement ("Out of scope: ... controller integration, service layer."). Recommend reverting and splitting to its own PR.
For context: I cross-checked all three against the SDS (sds/idp-mfa.md § 3.1, § 4.3, § 6) and the ClickUp ticket DOD (86b9h8xt1). All three are supported by both — they are additions/scope drift the spec does not ask for.
A second-pass review (Codex) independently confirmed all three. Two additional concerns I am not posting here:
- A minor design concern about
two_factor_method's non-nullemail_otpdefault — withdrawn after rechecking, since SDS § 3.1 explicitly prescribes that default. - A defensive-guard suggestion in
shouldRequire2FA()against misconfiguredenforced_groups(typo'd slugs, non-array) — nice-to-have, not required.
caseylocker
left a comment
There was a problem hiding this comment.
@matiasperrone-exo please see comments. Thanks.
fc6818d to
f522e54
Compare
|
📘 OpenAPI / Swagger preview ➡️ https://OpenStackweb.github.io/openstackid/openapi/pr-126/ This page is automatically updated on each push to this PR. |
f522e54 to
4b760a8
Compare
|
📘 OpenAPI / Swagger preview ➡️ https://OpenStackweb.github.io/openstackid/openapi/pr-126/ This page is automatically updated on each push to this PR. |
4b760a8 to
9146757
Compare
|
📘 OpenAPI / Swagger preview ➡️ https://OpenStackweb.github.io/openstackid/openapi/pr-126/ This page is automatically updated on each push to this PR. |
We are going to correct this typo in the SDS |
|
@caseylocker please review it again, I addressed all the named issues by moving the validation away from the setters, and leave the setters clean also reverted the unexpected changes in SocialLoginController.
|
caseylocker
left a comment
There was a problem hiding this comment.
Based on the requirements/ticket this LGTM.
Task:
Ref: https://app.clickup.com/t/86b9h8xt1
Changes
Verification:
Card Description
GOAL
Current state
The User entity (Auth\User) has no 2FA-related properties or methods. Role checking exists via isSuperAdmin() and isAdmin() but there is no mechanism to determine whether a user requires two-factor authentication.
Target state
The User entity exposes the three new database fields as Doctrine-mapped properties and provides the business logic methods needed by the controller and services:
shouldRequire2FA(), enable2FA(), getAvailableTwoFactorMethods(), isTwoFactorMethodEnable(), getTwoFactorMethod(), and the ValidMFAMethods constant.
TASKS
isTOTPConfirmed(), isPassKeyEnabled() return false.
ACCEPTANCE CRITERIA
DEVELOPMENT NOTES
Key files:
Gotchas:
config('two_factor.enforced_groups'), not hardcode group slugs.
Out of scope: Database migration (Ticket 1), controller integration, service layer.