Restrict the traffic limit exception UI to the growthbook-admin group
What?
Backend:
- Add an
isAuthorized(role)middleware toutil/auth.js, the role-aware counterpart toisAuthenticated: 401when the user is not logged in,403when logged in but missing the group,next()otherwise. - Read the group names from
req.user.rolesset byserializeUserinroutes/login.js - Export a
GROWTHBOOK_ADMIN_GROUPconstant for the traffic limit exception endpoints to require - Renamed
isAuthtoisAuthenticated
Frontend:
- Track the user's LDAP groups as
rolesin theuserAuthstore and add anisGrowthBookAdmingetter - Add a router check that redirects non-admins home from any route
flagged
meta: { requiresGrowthBookAdmin: true }when the user isn't an admin. - Grant the
growthbook-admingroup in the dev login bypass so the UI stays reachable locally where login is disabled
Tests:
- Add unit tests covering
isAuthorizedandgetUserGroups
Why?
- The traffic limit exception UI and the endpoints that manage it must be
available only to members of the
growthbook-adminLDAP group (T432310). isAuthonly checks that a user is logged in so a role-aware check is needed on the backend- The frontend needs the group membership to decide whether to expose the UI.
- The user's groups are already fetched at login so this wires that information into both layers.
- The UI (T432304) and its endpoints (T432305) build on the check and store getter added here.
Note:
userAuth is a persisted store so rename of role to roles allows anyone with an old session to see the persisted role key ignored on first load (a re-login refreshes it). Nothing consumed role before fwiw.
Assisted-by: Claude Opus 4.8
Bug: T432310