security: enforce disabled account check in auth middleware#268
Merged
security: enforce disabled account check in auth middleware#268
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR closes a security gap in the Go API server by enforcing the User.Disabled flag during identity resolution, preventing disabled accounts from authenticating across HTTP and WebSocket entrypoints (and the dev auth bypass) that rely on EnsureUser().
Changes:
- Add exported sentinel
ErrDisabledUserin the user repo package. - Update
EnsureUser()to reject existing users withDisabled=true. - Add a unit test verifying
EnsureUser()returnsErrDisabledUserfor disabled accounts.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| apiserver/internal/repos/user/user.go | Introduces ErrDisabledUser and blocks EnsureUser() from returning a disabled user. |
| apiserver/internal/repos/user/user_test.go | Adds coverage to ensure disabled users are rejected with the sentinel error. |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
Problem
The \User.Disabled\ field existed in the DB schema but was never checked during authentication. A disabled user could authenticate and access all HTTP and WebSocket endpoints.
Root Cause
\�erifyAccessToken(), \VerifyWSToken(), and \�ypassAuth()\ all call \EnsureUser()\ but the returned user's \Disabled\ field was never inspected.
Fix
*\�piserver/internal/repos/user/user.go*
This single change covers all three auth paths (HTTP, WebSocket, dev bypass) since they all flow through \EnsureUser(). The middleware already propagates errors as \401 Unauthorized, so no middleware changes were needed.
*\�piserver/internal/repos/user/user_test.go*
Testing
All 12 existing + new tests pass (\go test ./...).