Skip to content

feat: authentication and K8s RBAC-based authorization#214

Merged
nadaverell merged 2 commits intomainfrom
feature/auth-rbac
Mar 29, 2026
Merged

feat: authentication and K8s RBAC-based authorization#214
nadaverell merged 2 commits intomainfrom
feature/auth-rbac

Conversation

@nadaverell
Copy link
Copy Markdown
Contributor

@nadaverell nadaverell commented Feb 25, 2026

Closes #99

Summary

Adds optional authentication and RBAC-based authorization to Radar, allowing teams running it in shared environments (e.g., in-cluster) to control who can access the UI and what they can do.

Three auth modes:

  • none (default) — no change from current behavior
  • proxy — trust X-Forwarded-User / X-Forwarded-Groups headers from an upstream reverse proxy (oauth2-proxy, nginx, etc.)
  • oidc — full OpenID Connect login flow with session cookies

RBAC-aware authorization: when auth is enabled, write operations (restart, scale, rollback, delete, GitOps sync/suspend, etc.) are executed via K8s impersonation so the user's own RBAC permissions apply. Read endpoints filter namespaces to only those the user can access, discovered via SubjectAccessReview.

Topology stability: fixes the topology graph viewport jumping every ~3 seconds in active clusters. The ELK layout engine was triggering fitView on every background update; now fitView only runs on intentional actions (initial load, view mode change, explicit re-layout). Node positions are preserved across incremental updates. Adds a pause live updates button to the topology controls.

Key files

  • pkg/auth/ — reusable cookie signing, impersonation helpers, permission cache, RBAC namespace discovery
  • internal/auth/ — HTTP middleware (proxy/OIDC), audit logging
  • internal/k8s/impersonate.go — wires auth into K8s clients
  • internal/server/server.go — middleware mounting, parseNamespacesForUser, getDynamicClientForRequest
  • packages/k8s-ui/src/components/topology/TopologyGraph.tsx — viewport stability + pause button
  • web/src/components/UserMenu.tsx — user identity display when auth is enabled

Review fixes applied

  • handleWorkloadRevisions was using the shared cluster client (RBAC bypass) — now uses impersonated client
  • --auth-mode flag validated at startup to catch typos that would silently disable auth
  • Tampered/expired cookies are now logged for security monitoring
  • Proxy mode Secure cookie flag uses X-Forwarded-Proto instead of being hardcoded false
  • AuditLog moved before client nil check in Argo/Flux handlers so failed attempts are recorded
  • Added tests for ImpersonatedConfig field correctness and base config immutability

@nadaverell nadaverell requested a review from hisco as a code owner February 25, 2026 11:30
@nadaverell nadaverell force-pushed the feature/auth-rbac branch 4 times, most recently from 4477e62 to cde6897 Compare February 25, 2026 14:23
@nadaverell nadaverell changed the title feat: add authentication and K8s RBAC-based authorization feat: authentication and K8s RBAC-based authorization Mar 29, 2026
…fixes

Adds opt-in auth support for in-cluster radar deployments:

- **Proxy mode**: trusted header injection (X-Remote-User / X-Remote-Group) from
  an upstream auth proxy (OAuth2 Proxy, Pomerium, Cloudflare Access, etc.)
- **OIDC mode**: native OIDC/SSO login flow with Dex, Okta, GitHub, Google, etc.
- Session cookies (HMAC-signed) so subsequent requests don't repeat header/token checks
- K8s RBAC impersonation: all cluster operations run as the authenticated user,
  respecting existing ClusterRole/RoleBinding rules
- Namespace filtering: non-admin users only see namespaces they have access to
- Helm visibility: auto-grants secrets read RBAC so release history is visible
- Auth middleware with exempt paths (health, static assets) and soft-auth paths
- Full test coverage: middleware unit tests + integration tests for all auth paths
- Helm chart updates: auth env vars, RBAC ClusterRole for impersonation, deployment
  template for secret/configmap auth config mounts
- Documentation: docs/authentication.md with setup guide for all supported modes

Three fixes for topology graph shuffling observed in active clusters:

- **Position preservation**: after initial ELK layout, node positions are saved in a
  ref. Subsequent topology updates (new pods, status changes) preserve existing node
  positions — only newly-added nodes get ELK-computed positions. User-dragged
  positions are also preserved. Retry Layout button still forces a full fresh layout.

- **fitView on background updates**: ViewportController no longer calls fitView on
  every structural topology change. fitView only runs when nodes first appear, when
  view mode switches, or on explicit retry — not on every incremental SSE update.

- **Pause live updates button**: new control in the topology toolbar lets users freeze
  the graph snapshot while exploring. SSE connection stays live; updates are buffered
  and applied instantly on resume. Auto-unpauses on context switch.
…security

- Fix handleWorkloadRevisions to use impersonated client (RBAC bypass)
- Validate --auth-mode flag at startup to catch typos that silently disable auth
- Log tampered/expired cookies for security monitoring
- Fix Secure cookie flag in proxy mode to use X-Forwarded-Proto
- Move AuditLog before client nil check in argo/flux handlers so failed ops are logged
- Handle json.Marshal error in CreateSessionCookie with log.Fatalf
- Add tests for ImpersonatedConfig correctness and base config immutability
@nadaverell nadaverell merged commit ebd0262 into main Mar 29, 2026
5 of 6 checks passed
@nadaverell nadaverell deleted the feature/auth-rbac branch March 29, 2026 22:36
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.

Add User Authentication and Group-Based Access Control

1 participant