Feature | Add AuthService validateCredentials method#127
Feature | Add AuthService validateCredentials method#127matiasperrone-exo wants to merge 3 commits intofeat/mfa-phase1-user-modelfrom
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)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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-127/ This page is automatically updated on each push to this PR. |
133b2a8 to
1d8c6e4
Compare
d560647 to
f4ee340
Compare
|
📘 OpenAPI / Swagger preview ➡️ https://OpenStackweb.github.io/openstackid/openapi/pr-127/ This page is automatically updated on each push to this PR. |
f4ee340 to
a293dde
Compare
|
📘 OpenAPI / Swagger preview ➡️ https://OpenStackweb.github.io/openstackid/openapi/pr-127/ This page is automatically updated on each push to this PR. |
a293dde to
496a595
Compare
5f9b3a2 to
894cbe4
Compare
|
📘 OpenAPI / Swagger preview ➡️ https://OpenStackweb.github.io/openstackid/openapi/pr-127/ This page is automatically updated on each push to this PR. |
894cbe4 to
fc6818d
Compare
496a595 to
1bbe5ff
Compare
|
📘 OpenAPI / Swagger preview ➡️ https://OpenStackweb.github.io/openstackid/openapi/pr-127/ This page is automatically updated on each push to this PR. |
1bbe5ff to
e1bbb75
Compare
|
📘 OpenAPI / Swagger preview ➡️ https://OpenStackweb.github.io/openstackid/openapi/pr-127/ This page is automatically updated on each push to this PR. |
e1bbb75 to
ca405e6
Compare
|
📘 OpenAPI / Swagger preview ➡️ https://OpenStackweb.github.io/openstackid/openapi/pr-127/ This page is automatically updated on each push to this PR. |
1 similar comment
|
📘 OpenAPI / Swagger preview ➡️ https://OpenStackweb.github.io/openstackid/openapi/pr-127/ 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
smarcet
left a comment
There was a problem hiding this comment.
@matiasperrone-exo please review comments
@matiasperrone-exo @martinquiroga-exo changes on existent code are out of scope
anything like that should be discussed before any proposed changes
4b760a8 to
9146757
Compare
- test: cover canLogin()=false branch in validateCredentials() unit tests - docs: document known double-query cost in validateCredentials() - fix: use consistent error message in validateCredentials()
a810012 to
cfd3bb7
Compare
|
📘 OpenAPI / Swagger preview ➡️ https://OpenStackweb.github.io/openstackid/openapi/pr-127/ This page is automatically updated on each push to this PR. |
cfd3bb7 to
f1afe11
Compare
|
📘 OpenAPI / Swagger preview ➡️ https://OpenStackweb.github.io/openstackid/openapi/pr-127/ This page is automatically updated on each push to this PR. |
f1afe11 to
80972f0
Compare
|
📘 OpenAPI / Swagger preview ➡️ https://OpenStackweb.github.io/openstackid/openapi/pr-127/ This page is automatically updated on each push to this PR. |
|
📘 OpenAPI / Swagger preview ➡️ https://OpenStackweb.github.io/openstackid/openapi/pr-127/ This page is automatically updated on each push to this PR. |
ecd7cd3 to
6b5f96e
Compare
|
📘 OpenAPI / Swagger preview ➡️ https://OpenStackweb.github.io/openstackid/openapi/pr-127/ This page is automatically updated on each push to this PR. |
|
@martinquiroga-exo the ticket ask for but the code is not following that please re review it |
smarcet
left a comment
There was a problem hiding this comment.
@martinquiroga-exo @matiasperrone-exo please re review
6b5f96e to
5f3c28e
Compare
|
📘 OpenAPI / Swagger preview ➡️ https://OpenStackweb.github.io/openstackid/openapi/pr-127/ This page is automatically updated on each push to this PR. |
5f3c28e to
70ba198
Compare
Task:
Ref: https://app.clickup.com/t/86b9j51aa
Summary
Adds
validateCredentials()andloginUser()toAuthServiceas the foundation for the MFA two-step login flow. The new methods split what was previously a singlelogin()call into two discrete phases: verify the password (phase 1, no session) and establish the session (phase 2, after the second factor passes).Changes
app/libs/Auth/AuthService.phpvalidateCredentials(string $username, string $password): User— validates credentials viaAuth::getProvider()->retrieveByCredentials()without callingAuth::attempt(), so no session is established. Pre-checks the user's active state before touching the provider; if the account is locked it throws immediately with a distinct "is locked" message (the provider swallowsAuthenticationLockedUserLoginAttemptand returnsnull, masking the lock state). Security checkpoints such asLockUserCounterMeasurestill fire on provider-level failures.loginUser(User $user, bool $remember): void— thin wrapper aroundAuth::login()for use after the second factor is verified.getCurrentUser()— addedinstanceof Userguard to prevent a non-Userreturn type.login()— removed stale$this->last_login_error = ""line and duplicated@paramsdocblock entry.app/libs/Utils/Services/IAuthService.phpvalidateCredentials()andloginUser()to the interface with full doc-blocks explaining the session-safety contract.Tests
tests/unit/AuthServiceValidateCredentialsTest.php— isolated unit tests (Mockery alias mocks forAuthandLogfacades, run in separate processes). Covers: valid credentialsreturn user without session, invalid credentials throw
AuthenticationException, locked account short-circuits before calling the provider, active user does not take the locked path,loginUser()withremember = true/false.tests/AuthServiceValidateCredentialsIntegrationTest.php— integration test against the real database and security-checkpoint stack. Verifies that a failedvalidateCredentials()call incrementslogin_failed_attemptviaLockUserCounterMeasure, and that a successful call returns theUserentity without establishing a session (Auth::check()staysfalse).Test plan
docker compose exec app ./vendor/bin/phpunit tests/unit/AuthServiceValidateCredentialsTest.phpdocker compose exec app ./vendor/bin/phpunit tests/AuthServiceValidateCredentialsIntegrationTest.phpdocker compose exec app ./vendor/bin/phpunitRequested Goal
Current state
AuthService::login() validates credentials AND establishes a session in a single call. There is no way to validate a user's password without logging them in, which is required to insert a 2FA gate between credential validation and session establishment.
Target state
AuthService exposes a new validateCredentials(string $username, string $password): User method that validates the password via the existing CustomAuthProvider::retrieveByCredentials() (which handles attempt tracking and account locking via security checkpoints) and returns the authenticated User object WITHOUT establishing a
session. Throws AuthenticationException on failure.
TASKS
ACCEPTANCE CRITERIA
DEVELOPMENT NOTES
Key files:
Gotchas:
and lock countermeasures.
Out of scope:
Controller changes