Repository navigation
feat: add generic OIDC auth provider - #40
Conversation
Add `type = "oidc"` to [[auth.providers]] so any OpenID Connect
provider that supports discovery (Authentik, Auth0, Authelia, Zitadel,
VoidAuth, ...) can be used without a dedicated integration.
The provider resolves the authorization, token, and userinfo endpoints
from <issuer_url>/.well-known/openid-configuration and caches them after
the first successful fetch. The rest of the flow mirrors the Keycloak
and Okta providers.
An optional `name` field sets the sign-in button label ("Continue with
Authentik"); it defaults to "SSO". The providers endpoint exposes it as
`label`.
Docs: new authentication/oidc page, config reference, overview and
audit-log provider list updated.
Closes #38
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
[Critical impact] The PR adds a sign-in path that reaches account access in deployments that enable OIDC. Support HTTP Basic authentication for token requests before merging so compatible OIDC providers can complete sign-in. Findings
SummaryAdds a generic OIDC sign-in provider with discovery and a configurable button label.
DiagramsequenceDiagram
participant User
participant Console as pgconsole
participant Provider as OIDC provider
User->>Console: Choose SSO
Console->>Provider: Fetch discovery on first use
Provider-->>Console: Authorization, token, and userinfo endpoints
Console-->>User: Redirect with state
User->>Provider: Sign in
Provider-->>Console: Callback with code and state
Console->>Console: Check state
Console->>Provider: Exchange code
Console->>Provider: Fetch userinfo
Console->>Console: Check email against allowed users
Console-->>User: Set session and redirect
Reviews (1) · Last reviewed commit: "feat: add generic OIDC auth provider" · Reviewed by Greptile |
There was a problem hiding this comment.
🟡 Changes recommended
The OIDC callback accepts explicitly unverified emails, enabling impersonation of allowlisted users when an identity provider permits self-registration or unverified email changes.
4 open issues
What changed in this PR
Adds a generic OIDC authentication provider to support discovery-based identity providers without dedicated integrations, addressing issue #38.
Changes:
- Implements OIDC discovery, sign-in, callback handling, and provider configuration.
- Adds configurable sign-in labels and OIDC identity-provider support.
- Documents setup, configuration, and audit-log integration.
| File | Description |
|---|---|
src/lib/auth-client.ts |
Adds optional provider display labels. |
src/components/AuthForm.tsx |
Adds the OIDC sign-in button and custom labels. |
server/lib/oauth/oidc.ts |
Implements discovery and the OIDC authentication flow. |
server/lib/config.ts |
Accepts OIDC configuration and optional names. |
server/lib/auth.ts |
Adds OIDC to user and token provider types. |
server/auth-routes.ts |
Registers OIDC routes and exposes provider labels. |
docs/features/audit-log.mdx |
Updates the documented authentication provider list. |
docs/docs.json |
Adds the OIDC guide to navigation. |
docs/configuration/config.mdx |
Documents OIDC fields and configuration examples. |
docs/authentication/overview.mdx |
Links OIDC from the authentication overview. |
docs/authentication/oidc.mdx |
Adds the OIDC setup guide. |
Review effort: Balanced
…users to docs Address review feedback on the generic OIDC provider: - Read token_endpoint_auth_methods_supported from the discovery document and send client credentials via HTTP Basic when the provider supports client_secret_basic (or advertises nothing, the RFC 6749 default). Fall back to client_secret_post form-body credentials otherwise. - Reject userinfo responses with email_verified: false before looking up the local user, matching the Google provider's verified_email check. - Add [[users]] entries to the setup example in docs/authentication/oidc.mdx so copying it into a fresh config starts successfully. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Build the authorize redirect with URL.searchParams so OAuth parameters merge into any query string the discovered authorization_endpoint already carries (e.g. ?tenant=... or ?p=...), instead of appending a second "?". Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
There was a problem hiding this comment.
🟡 Changes recommended
OIDC sign-in can grant sessions for unverified allowlisted emails, while authorization URL construction and client authentication selection can also cause valid provider configurations to fail.
2 open issues
4 resolved since last review
Review effort: Balanced
Discovery lists the methods the server supports, not the one a given
client is registered for. Some providers (e.g. Authelia) enforce the
per-client method, so a client registered for client_secret_post fails
when pgconsole picks Basic from discovery.
Add an optional `token_auth_method` field ("client_secret_basic" or
"client_secret_post") on oidc providers. When set it wins; when omitted
the method is still inferred from discovery as before. Invalid values
are rejected at config load.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
There was a problem hiding this comment.
🔵 Needs a closer look
The code always selects Basic when both methods are advertised, causing token exchanges to fail with invalid_client for clients registered to use POST, with no client-level override.
No open issues 🎉
2 resolved since last review
Review effort: Balanced



Summary
Adds
type = "oidc"to[[auth.providers]]so any OpenID Connect provider that supports discovery (Authentik, Auth0, Authelia, Zitadel, VoidAuth, ...) works without a dedicated integration.Closes #38
Changes
server/lib/oauth/oidc.ts: new provider. Resolves authorization, token, and userinfo endpoints from<issuer_url>/.well-known/openid-configuration, cached after first success. Discovery failure returns 502 on the sign-in route. Token exchange and userinfo handling mirror the Keycloak and Okta providers.server/lib/config.ts: acceptoidc, requireissuer_urlfor it, parse optionalname.server/lib/auth.ts: widenidpunion.server/auth-routes.ts: register route;/api/auth/providersnow includeslabelwhen a name is configured.src/components/AuthForm.tsx,src/lib/auth-client.ts: sign-in button using the label.authentication/oidcpage, config reference, overview, audit-log provider list, nav.Design notes
openid email profile; email is required as the identity key, same as the other providers.oidcprovider, consistent with lookup-by-type for the existing types.namefollows the optional display-name convention already used by[[ai.providers]]and[[agents]].Verification
pnpm build:server,tsc -b, direct typecheck of server auth files, and eslint on changed files: clean.redirect_uri, scopes, and state; two sign-in requests produce one discovery fetch; callback with mismatched state redirects to/signin?error=invalid_state.issuer_urlforoidcfails to load with a clear error.🤖 Generated with Claude Code