Restrict the traffic limit exception UI to the growthbook-admin group

What?

Backend:

  • Add an isAuthorized(role) middleware to util/auth.js, the role-aware counterpart to isAuthenticated: 401 when the user is not logged in, 403 when logged in but missing the group, next() otherwise.
  • Read the group names from req.user.roles set by serializeUser in routes/login.js
  • Export a GROWTHBOOK_ADMIN_GROUP constant for the traffic limit exception endpoints to require
  • Renamed isAuth to isAuthenticated

Frontend:

  • Track the user's LDAP groups as roles in the userAuth store and add an isGrowthBookAdmin getter
  • 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-admin group in the dev login bypass so the UI stays reachable locally where login is disabled

Tests:

  • Add unit tests covering isAuthorized and getUserGroups

Why?

  • The traffic limit exception UI and the endpoints that manage it must be available only to members of the growthbook-admin LDAP group (T432310).
  • isAuth only 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

Edited by Clare Ming

Merge request reports

Loading