Skip to content

Add OAuth JWT auth for dashboard API#2499

Draft
dobrac wants to merge 33 commits intomainfrom
add-dashboard-oauth-jwks
Draft

Add OAuth JWT auth for dashboard API#2499
dobrac wants to merge 33 commits intomainfrom
add-dashboard-oauth-jwks

Conversation

@dobrac
Copy link
Copy Markdown
Contributor

@dobrac dobrac commented Apr 25, 2026

Motivation

Dashboard and API auth were tied to Supabase-specific HMAC JWT configuration (SUPABASE_JWT_SECRETS) and Supabase-specific headers. That made it hard to support other auth providers that issue JWTs signed with JWKS, and it forced provider-specific settings to spread across several environment variables.

This change introduces one generic auth-provider JWT verification path that supports both existing Supabase-style HMAC tokens and JWKS-backed providers. It keeps the old Supabase headers as compatibility aliases, while adding provider-neutral bearer token and team header schemes.

Summary

  • Add shared auth-provider JWT verification with HMAC and JWKS verifier strategies.
  • Support multiple configured JWT verifier strategies at the same time, useful during migration from legacy HMAC to JWKS.
  • Replace API/dashboard service-level SUPABASE_JWT_SECRETS with one structured AUTH_PROVIDER_CONFIG JSON value.
  • Default API/dashboard auth-provider config to HMAC using the existing Supabase JWT secret when explicit config is not supplied.
  • Use github.com/MicahParks/keyfunc/v3/jwkset for JWKS lookup, caching, and refresh.
  • Require JWKS URLs to use HTTPS.
  • Require user_id_claim to resolve directly to an internal UUID; no email fallback.
  • Wire auth-provider bearer token and X-Team-Id team header in both API and dashboard API, while keeping Supabase headers as compatibility aliases.

Config shape

JWKS:

{
  "jwt": {
    "issuer": "https://issuer.example.com",
    "audience": "dashboard-api",
    "user_id_claim": "sub",
    "jwks": {
      "url": "https://issuer.example.com/.well-known/jwks.json",
      "cache_duration": "5m"
    }
  }
}

HMAC:

{
  "jwt": {
    "user_id_claim": "sub",
    "hmac": {
      "secrets": ["secret-1", "secret-2"]
    }
  }
}

Both can be configured together during migration/rotation:

{
  "jwt": {
    "issuer": "https://issuer.example.com",
    "audience": "dashboard-api",
    "user_id_claim": "sub",
    "hmac": {
      "secrets": ["legacy-secret"]
    },
    "jwks": {
      "url": "https://issuer.example.com/.well-known/jwks.json",
      "cache_duration": "5m"
    }
  }
}
Open in Web Open in Cursor 

Co-authored-by: Jakub Dobry <dobrac@users.noreply.github.com>
github-actions Bot and others added 3 commits April 25, 2026 05:38
Co-authored-by: Jakub Dobry <dobrac@users.noreply.github.com>
Co-authored-by: Jakub Dobry <dobrac@users.noreply.github.com>
Copy link
Copy Markdown

@claude claude Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test review

Comment thread packages/auth/pkg/auth/oauth.go Outdated
Comment thread packages/auth/pkg/auth/oauth.go Outdated
Comment thread packages/auth/pkg/auth/oauth.go Outdated
Comment thread packages/auth/pkg/auth/service.go
Comment thread spec/openapi-dashboard.yml
Co-authored-by: Jakub Dobry <dobrac@users.noreply.github.com>
Comment thread packages/auth/pkg/auth/jwt.go Outdated
Comment thread packages/auth/pkg/auth/service.go Outdated
cursoragent and others added 2 commits April 25, 2026 06:19
Co-authored-by: Jakub Dobry <dobrac@users.noreply.github.com>
Co-authored-by: Jakub Dobry <dobrac@users.noreply.github.com>
Comment thread iac/provider-gcp/nomad/variables.tf
cursoragent and others added 9 commits April 25, 2026 06:27
Co-authored-by: Jakub Dobry <dobrac@users.noreply.github.com>
Co-authored-by: Jakub Dobry <dobrac@users.noreply.github.com>
Co-authored-by: Jakub Dobry <dobrac@users.noreply.github.com>
Co-authored-by: Jakub Dobry <dobrac@users.noreply.github.com>
Co-authored-by: Jakub Dobry <dobrac@users.noreply.github.com>
Co-authored-by: Jakub Dobry <dobrac@users.noreply.github.com>
Co-authored-by: Jakub Dobry <dobrac@users.noreply.github.com>
Co-authored-by: Jakub Dobry <dobrac@users.noreply.github.com>
Comment thread iac/modules/job-api/main.tf
cursoragent and others added 4 commits April 25, 2026 07:05
Co-authored-by: Jakub Dobry <dobrac@users.noreply.github.com>
Co-authored-by: Jakub Dobry <dobrac@users.noreply.github.com>
Co-authored-by: Jakub Dobry <dobrac@users.noreply.github.com>
Comment thread iac/provider-aws/nomad/variables.tf
cursoragent and others added 5 commits April 25, 2026 07:17
Co-authored-by: Jakub Dobry <dobrac@users.noreply.github.com>
Co-authored-by: Jakub Dobry <dobrac@users.noreply.github.com>
Co-authored-by: Jakub Dobry <dobrac@users.noreply.github.com>
Co-authored-by: Jakub Dobry <dobrac@users.noreply.github.com>
Comment thread packages/dashboard-api/main.go
Co-authored-by: Jakub Dobry <dobrac@users.noreply.github.com>
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 12e42ef. Configure here.

Comment thread iac/provider-aws/nomad/main.tf
Comment thread packages/api/Makefile
cursoragent and others added 7 commits April 27, 2026 21:42
Co-authored-by: Jakub Dobry <dobrac@users.noreply.github.com>
Co-authored-by: Jakub Dobry <dobrac@users.noreply.github.com>
Co-authored-by: Jakub Dobry <dobrac@users.noreply.github.com>
Co-authored-by: Jakub Dobry <dobrac@users.noreply.github.com>
Co-authored-by: Jakub Dobry <dobrac@users.noreply.github.com>
Co-authored-by: Jakub Dobry <dobrac@users.noreply.github.com>
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.

3 participants