Closed
Conversation
The requirePermissions middleware validates JWT roles against WXYCRoles, but WXYCRoles only included member, dj, musicDirector, and stationManager. Users whose organization member role is "admin" get 403 "Invalid role" on every authenticated request because WXYCRoles["admin"] is undefined. Add an admin role definition with the same permissions as stationManager (plus adminAc org-management statements) and register it in WXYCRoles so the middleware recognizes it. Also add unit tests for all WXYCRoles definitions and the mocks needed to test better-auth access control modules under Jest.
Tests the exact code path that caused Jackson's 403 bug: a JWT with role="admin" going through requirePermissions. Verifies the middleware calls next() instead of returning 403 "Invalid role" now that WXYCRoles includes admin.
The _prefix convention for unused params was configured for apps/ and shared/ but not for tests/. This caused a lint error on the _statements param in the better-auth mock.
Jest mock assertions like expect(res.status).toHaveBeenCalled() trigger false positives from @typescript-eslint/unbound-method. This is already downgraded to warn for app/shared code.
Member
Author
|
Closing: admin is a better-auth system role ( The test infrastructure in this PR (mocks, parameterized middleware tests) can be cherry-picked into a future PR. The 403 bug for users with
|
jakebromberg
pushed a commit
that referenced
this pull request
Feb 14, 2026
Proposal 1 converges the auth model across wxyc-shared, Backend-Service, and dj-site by removing admin from the station role hierarchy. Proposal 2 adds cross-cutting capabilities (editor, webmaster) end-to-end from Backend-Service storage through JWT to dj-site UI. Proposal 1 status: - wxyc-shared admin removal: done (PR WXYC/wxyc-shared#8) - Backend-Service PR #156: closed - Org hooks audit: completed, hooks are safe - Remaining: re-add organizationClient, isAdmin in JWT, dj-site adoption
1 task
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
adminrole definition toWXYCRolesso therequirePermissionsmiddleware recognizes itadminrole has the same permissions asstationManagerplus better-auth'sadminAcorg-management statementsProblem
The
requirePermissionsmiddleware validates JWT roles againstWXYCRoles. On main, onlymember,dj,musicDirector, andstationManagerare recognized. However, the auth system can assign"admin"as an organization member role (via the admin panel, org hooks, or better-auth's built-in roles). When that happens, the JWT containsrole: "admin", butWXYCRoles["admin"]isundefined, causing 403 "Forbidden: Invalid role" on every authenticated request.Test plan
member.role = 'admin'can access protected endpoints