Skip to content

feat: add built-in OIDC authentication support#3607

Open
yaswanthkumar1995 wants to merge 2 commits intohatchet-dev:mainfrom
yaswanthkumar1995:feat/oidc-support
Open

feat: add built-in OIDC authentication support#3607
yaswanthkumar1995 wants to merge 2 commits intohatchet-dev:mainfrom
yaswanthkumar1995:feat/oidc-support

Conversation

@yaswanthkumar1995
Copy link
Copy Markdown

Description

Add native OIDC authentication support for self-hosted Hatchet instances, enabling direct SSO integration with any OpenID Connect compliant provider (Keycloak, PocketID, Okta, Azure AD, etc.) without requiring external proxies like oauth2-proxy or Traefik forward auth.

Uses standard OIDC discovery (.well-known/openid-configuration) to auto-resolve authorization and token endpoints at startup, and verifies ID tokens using the provider's JWKS.

Closes #3052

Type of change

  • New feature (non-breaking change which adds functionality)

What's Changed

  • Add oidc_oauth_start.go and oidc_oauth_callback.go handlers following the existing Google/GitHub OAuth pattern
  • Add ConfigFileAuthOIDC config struct with env var bindings (SERVER_AUTH_OIDC_ENABLED, _CLIENT_ID, _CLIENT_SECRET, _ISSUER_URL, _SCOPES)
  • Cache oidc.Provider at startup for ID token verification (no per-request OIDC discovery)
  • Add OIDC routes to OpenAPI spec (/api/v1/users/oidc/start, /api/v1/users/oidc/callback) and regenerate server code
  • Expose oidc auth scheme via /api/v1/meta endpoint
  • Add SSO button with lock icon to frontend auth page
  • Support existing domain restrictions for OIDC users
  • Default scopes: openid, profile, email
  • Uses github.com/coreos/go-oidc/v3 for discovery and token verification

Add native OIDC support for self-hosted instances, enabling direct
integration with providers like Keycloak, PocketID, and any
OpenID Connect compliant identity provider.

Changes:
- Add OIDC OAuth2 start and callback handlers
- Add OIDC config struct with env var bindings (SERVER_AUTH_OIDC_*)
- Use OIDC discovery to resolve auth/token endpoints at startup
- Cache oidc.Provider for ID token verification (no per-request discovery)
- Add OIDC routes to OpenAPI spec and regenerate server code
- Expose 'oidc' scheme via /api/v1/meta endpoint
- Add SSO button to frontend auth page
- Support domain restrictions for OIDC users
- Default scopes: openid, profile, email

Closes hatchet-dev#3052
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 12, 2026

@yaswanthkumar1995 is attempting to deploy a commit to the Hatchet Team on Vercel.

A member of the Team first needs to authorize it.

@promptless-for-oss
Copy link
Copy Markdown

Promptless prepared a documentation update related to this change.

Triggered by PR #3607

Documents the new OIDC SSO authentication feature for self-hosted instances, adding configuration environment variables (SERVER_AUTH_OIDC_ENABLED, _CLIENT_ID, _CLIENT_SECRET, _ISSUER_URL, _SCOPES) and usage instructions to the self-hosting configuration options page.

Review at https://app.gopromptless.ai/suggestions/df488012-3df4-4f69-8942-265949397153

@yaswanthkumar1995
Copy link
Copy Markdown
Author

Hi @abelanger5 @mnafees - this implements the oidc support from #3052 kindly review it

- Add nil guards for OIDCOAuthConfig/OIDCProvider in both handlers to
  prevent nil pointer panic when OIDC is disabled
- Move AllowSignup check from start handler to CreateUser path so
  existing OIDC users can still log in when signup is disabled
- Require email_verified before authorizing or linking by email
- Add UserInfo endpoint fallback when ID token lacks optional claims
  (email, name, email_verified)
- Validate UserInfo sub claim matches ID token sub per OIDC spec
- Normalize BaseURL with TrimRight to prevent double-slash redirect URIs
- Add 30s timeout context for OIDC discovery at startup
- Enforce 'openid' scope is always present in configured scopes
- Add ScopesString field for reliable env var binding and parse it
  before building OIDCOAuthConfig so SERVER_AUTH_OIDC_SCOPES works
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.

[FEAT] OIDC Support

2 participants