Conversation
A user carrying the global suspend flag could still authenticate. Login did not check the flag; and even with that check, the other token-minting paths did not -- so an already-authenticated user kept full access after being suspended. RefreshToken re-issues a 7-day refresh token on every call, letting a live client roll its session indefinitely, and VerifyFactor completed any 2FA login whose state token was minted before the suspension landed. Add a rejectIfSuspended helper and call it on every path that mints a token: - Login: after password validation, before the MFA challenge, so a suspended 2FA user is refused without leaking an MFA_REQUIRED state token. - RefreshToken: after the user is loaded, before the refresh token is consumed, so no new token pair is issued. - VerifyFactor: after the user is loaded, before 2FA completes. All three return 403 with an identical message so the response does not reveal which check fired. Document the 403 on the Login endpoint and regenerate the Swagger definitions. Tests: Login suspended cases (403, no Set-Cookie, no MFA_REQUIRED leak) as a struct table; unit coverage of the RefreshToken and VerifyFactor paths (TestAuthenticationController_SuspendedAccountCannotMintTokens); and an integration test that creates a suspended user and asserts Login returns 403.
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 4 |
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A user carrying the global suspend flag could still authenticate. Login
did not check the flag; and even with that check, the other token-minting
paths did not -- so an already-authenticated user kept full access after
being suspended. RefreshToken re-issues a 7-day refresh token on every
call, letting a live client roll its session indefinitely, and
VerifyFactor completed any 2FA login whose state token was minted before
the suspension landed.
Add a rejectIfSuspended helper and call it on every path that mints a
token:
suspended 2FA user is refused without leaking an MFA_REQUIRED state
token.
consumed, so no new token pair is issued.
All three return 403 with an identical message so the response does not
reveal which check fired. Document the 403 on the Login endpoint and
regenerate the Swagger definitions.
Tests: Login suspended cases (403, no Set-Cookie, no MFA_REQUIRED leak)
as a struct table; unit coverage of the RefreshToken and VerifyFactor
paths (TestAuthenticationController_SuspendedAccountCannotMintTokens);
and an integration test that creates a suspended user and asserts Login
returns 403.