Skip to content

feat(auth): grant platform admin by OIDC subject in gateway config - #2701

Draft
jhjaggars wants to merge 2 commits into
NVIDIA:mainfrom
jhjaggars:feat/admin-subjects
Draft

feat(auth): grant platform admin by OIDC subject in gateway config#2701
jhjaggars wants to merge 2 commits into
NVIDIA:mainfrom
jhjaggars:feat/admin-subjects

Conversation

@jhjaggars

Copy link
Copy Markdown
Contributor

Summary

Add admin_subjects to the OIDC gateway config — a list of OIDC subject (sub claim) values that are granted Platform Admin regardless of their JWT role claims. Works alongside admin_role — either mechanism grants admin access. This is a no-op in auth-only mode (when both admin_role and user_role are empty).

This enables granting admin to specific identity-provider users without requiring a dedicated admin role assignment in the IdP, which is useful for bootstrapping, break-glass access, and IdPs where role management is inconvenient.

Related Issue

No issue required: self-contained auth enhancement with config, server, Helm, and docs changes in a single commit.

Changes

  • openshell-core: Add admin_subjects: Vec<String> to OidcConfig (serde-default, backward compatible).
  • openshell-server/auth/authz.rs: AuthzPolicy gains admin_subjects: HashSet<String>. Role checks now also pass if the caller's sub is in admin_subjects.
  • openshell-server/auth/workspace_authz.rs: Extract AdminPolicy struct bundling admin_role + admin_subjects. Replace bare &str admin-role parameters with &AdminPolicy across authorize_workspace, authorize_sandbox_workspace, require_platform_admin, and is_platform_admin_principal.
  • openshell-server gRPC handlers: Thread AdminPolicy through all RPC handlers that check platform admin (sandbox, workspace, policy, provider, inference, service).
  • openshell-server/cli.rs: Log admin_subjects count at startup when non-empty.
  • Helm chart: Add server.oidc.adminSubjects list value, render admin_subjects = [...] in gateway-config.yaml.
  • Docs: Add admin_subjects row to docs/reference/gateway-config.mdx.

Testing

  • mise run pre-commit passes
  • Unit tests added/updated (authz.rs: 3 new tests, workspace_authz.rs: 4 new tests)
  • Validated on dev cluster (ROSA, Keycloak): removed openshell-admin role from test user, confirmed Platform Admin access via admin_subjects match alone
  • E2E tests added/updated (not applicable — OIDC e2e infra does not yet support per-user subject assertions)

Checklist

  • Follows Conventional Commits
  • Commits are signed off (DCO)

Add admin_subjects to the gateway OIDC configuration — a list of OIDC
sub claim values that are granted Platform Admin privileges regardless
of their JWT role claims. Works alongside the existing admin_role
check: either mechanism grants admin access.

Introduce AdminPolicy struct that bundles admin_role and admin_subjects,
replacing the flat admin_role: String threading through ServerState and
all gRPC handler call sites. This localizes the admin-grant logic and
prevents future churn if more admin criteria are added.

The feature supports the single-owner gateway use case where the IdP
does not carry OpenShell-specific roles. A gateway operator configures
their own sub as an admin subject and uses OIDC purely for identity.

- Config: admin_subjects field on OidcConfig (Vec<String>)
- CLI: --oidc-admin-subjects flag, OPENSHELL_OIDC_ADMIN_SUBJECTS env var
- Middleware RBAC: AuthzPolicy.admin_subjects checked in check()
- Workspace authz: AdminPolicy.admin_subjects checked in is_platform_admin()
- Helm: server.oidc.adminSubjects value and template rendering
- Docs: gateway-config.mdx updated with new TOML field
- Tests: 6 new tests covering subject-based admin, role coexistence,
  auth-only no-op, and negative cases

Closes NVIDIA#2613

Signed-off-by: Jesse Jaggars <jjaggars@redhat.com>
@copy-pr-bot

copy-pr-bot Bot commented Aug 11, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

When admin_subjects is configured but admin_role and user_role are empty,
the previous code still treated every authenticated user as Platform Admin
(auth-only mode). Now auth-only mode only activates when both admin_role
and admin_subjects are empty.

With admin_subjects set and roles empty:
- Admin methods are restricted to listed subjects only
- User-level methods remain open to all authenticated callers

Signed-off-by: Jesse Jaggars <jjaggars@redhat.com>
@jhjaggars
jhjaggars force-pushed the feat/admin-subjects branch from 022ba20 to 6483725 Compare August 11, 2026 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant