Scope admin user badges to their area
What does this MR do and why?
In the organization admin area, badges that describe instance-level privileges
and licensing were rendered for organization owners. An Admin badge in that
context is ambiguous (it reads as "admin of this organization" when it actually
means instance administrator) and, together with Auditor, External, and
Is using seat, it exposes instance-level information that organization owners
should not see.
The data behind these badges (admin, auditor, external, license-seat usage) is
already gated elsewhere by read_admin_users on :global — for example the REST
API exposes is_admin, is_auditor and using_license_seat behind that same
check. So this MR gates the instance badges with read_admin_users on :global
rather than introducing a badge-specific permission that would drift from the
other places the same data is exposed.
user_badges_in_admin_section routes to instance_user_badges or
organization_user_badges based on whether an organization context is present:
instance_user_badgesreturns the instance-level badges only when the viewer hasread_admin_userson:global. Instance admins and custom admin roles withread_admin_usershave it; organization owners do not.organization_user_badgesreturns theOrganization adminbadge, which is just the user's organization access level. The caller already authorizesread_organization_user, so no extra check is needed.
Badges split into:
- Instance-level (shown to instance admins only):
Admin,Auditor,External,Is using seat. - Organization-scoped (shown to organization admins):
Organization admin. - Common (not sensitive, shown in both areas):
Blocked,Bot,Deactivated,Locked,Placeholder,LDAP,It's you!. These match what group and project member lists already surface.
It also fixes a disclosure on the organization Users GraphQL page
(OrganizationUserType#badges), which called user_badges_in_admin_section
without an organization context and so rendered instance badges to organization
owners. The organization is now passed through, and the permission check backs
it up.
The email/note gating in !257399 (merged) is a related but separate change; it will be reconciled with this context-and-permission approach after that MR merges.
References
- Related: !257399 (merged)
Screenshots or screen recordings
| Before | After | |
|---|---|---|
| Organization admin | ![]() |
![]() |
| Instance admin | ![]() |
![]() |
How to set up and validate locally
- Sign in as an instance admin and confirm a user shows the
Adminbadge in the instance admin area (/admin/users). - As a non-admin, create an organization and open Manage organization.
- Add the instance admin user to the organization.
- On the organization Users list, confirm the
Admin(and, on EE,Auditor,External,Is using seat) badges are no longer shown. - Make a user an organization owner and confirm the
Organization adminbadge still appears there.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.



