fix: prevent blocked admins from retaining access - #27
Merged
Conversation
|
@comwanga is attempting to deploy a commit to the Megasley Team on Vercel. A member of the Team first needs to authorize it. |
comwanga
marked this pull request as ready for review
September 8, 2026 18:41
Owner
|
Thank you very much! Reviewed and verified independently, tests (129/129) and typecheck pass in an isolated worktree, and the three fix layers (active-account gate, session revocation, self/last-admin guard) are correctly wired end-to-end. Merging. Two follow-ups to track separately, neither blocking: the last-admin check has a TOCTOU race (unlocked count read outside the transaction) under concurrent admin actions, and the new repository-layer logic (self/last-admin, session revocation) has no test coverage yet. Closes #23. |
This was referenced Sep 8, 2026
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.
Summary
Closes #23.
Suspended or banned administrators could retain a valid Supabase session and continue calling administrative server actions. Because the admin authorization gate checked only authentication and role, a blocked admin could potentially restore their own account.
What changed
1. Require an active account for privileged access
requireAdmin()now runsrequireActiveAccount()before checking the admin role.2. Revoke sessions on suspension and ban
auth.sessionstable.3. Protect administrator recovery paths
Security outcome
The original self-restore path is closed at multiple layers:
requireAdmin().Verification
npm test— 129 tests passednpx tsc --noEmit --pretty falsegit diff --checkI also added focused regression tests covering suspended and banned admin rejection, active non-admin rejection, and active admin access.