Skip to content

feat(auth): add a generic OIDC provider - #2405

Open
mxzinke wants to merge 4 commits into
CapSoftware:mainfrom
adapt2move:feat/generic-oidc-provider
Open

mxzinke wants to merge 4 commits into
CapSoftware:mainfrom
adapt2move:feat/generic-oidc-provider

Conversation

@mxzinke

@mxzinke mxzinke commented Oct 1, 2026 •

Copy link
Copy Markdown

Self-hosted instances can use Google, Apple and WorkOS today, but none of those work with an identity provider the operator runs themselves. This adds a generic OpenID Connect provider.

NextAuth already speaks OIDC, so this declares a provider from the discovery document rather than adding a dependency or a second code path. Closes the gap asked about in #914.

Usage

Set all three to show the button, leave any unset and nothing changes:

OIDC_ISSUER=https://id.example.com
OIDC_CLIENT_ID=...
OIDC_CLIENT_SECRET=...
OIDC_NAME=Example SSO      # optional, labels the button, defaults to "SSO"

OIDC_ISSUER is the base URL whose /.well-known/openid-configuration describes the endpoints, so any conformant provider works without further code.

Scope

81 lines across five files: the env schema, the provider, the public-env flag and the login button. No new dependency, no change to existing providers, no migration.

Two decisions worth calling out:

  • Email account linking is enabled, matching the WorkOS provider directly above it. An operator who configures this controls the issuer and its email claim, and without it an instance that already has email-code users cannot move them to SSO.
  • Signup restrictions already apply. The signIn callback keys on the address rather than the provider, so CAP_ALLOWED_SIGNUP_DOMAINS and the block list cover this provider with no extra code.

Deliberately not included, to keep the change small: the signup page and the share-page auth overlay keep their current buttons. New users sign in through /login and the account is created on first sign-in, so the flow is complete without them. Happy to add either if you would rather have them in the same PR.

Testing

I do not have a working build of the monorepo available, so this is reviewed rather than built: each touched file parses, and the provider follows the shape NextAuth v4 documents for a custom OIDC provider (wellKnown plus idToken). Please treat the CI run as the real check.

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge; no new actionable issues were found.

Summary

Adds a generic OIDC provider for self-hosted instances.

  • Self-hosted logins can use an operator's OIDC issuer.

The previous and current commits have different merge bases with the target commit, so this review used the full PR diff. No build or runtime checks were performed.

Reviews (2) · Last reviewed commit: "Merge branch 'CapSoftware:main' into fea..." · Reviewed by Greptile

Self-hosted instances can already use Google, Apple and WorkOS, but none of
those work with an identity provider the operator runs themselves. NextAuth
already speaks OIDC, so this only declares a provider from the discovery
document rather than adding a dependency or a second code path.

Set OIDC_ISSUER, OIDC_CLIENT_ID and OIDC_CLIENT_SECRET to show the button;
leave any of them unset and nothing changes. OIDC_NAME labels it.

Email account linking matches the WorkOS provider: an operator configuring this
controls the issuer and its email claim. CAP_ALLOWED_SIGNUP_DOMAINS and the
block list already apply, because the signIn callback keys on the address
rather than the provider.
Comment thread packages/database/auth/auth-options.ts
Comment thread packages/database/auth/auth-options.ts Outdated
Comment thread packages/database/auth/auth-options.ts Outdated
Comment thread packages/env/server.ts Outdated
A generic issuer is not known to verify addresses, so account linking on the
email claim alone would let an issuer that accepts unverified addresses take
over an existing account. The signIn callback now rejects the sign-in unless the
claims carry an email and email_verified is true, which also removes the crash
when an issuer omits the claim entirely and the adapter lowercases undefined.

Replaces the Record<string, any> profile annotation with a declared claim type,
drops the comments that only narrated the configuration, and passes the sign-in
handler into NormalLogin, where the button actually lives.
@richiemcilroy

Copy link
Copy Markdown
Member

Thanks, this looks like a clean approach. We require Greptile 5/5 on the latest commit and green CI before review, so please trigger a Greptile re-review now that account linking requires a verified email.

@mxzinke

mxzinke commented Oct 7, 2026

Copy link
Copy Markdown
Author

@richiemcilroy I get a 404 when trying to retrigger. Can you retrigger for me?

@vercel

vercel Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
cap-status Skipped Skipped Oct 18, 2026 5:08pm UTC

@vercel
vercel Bot temporarily deployed to Preview – cap-status October 15, 2026 13:04 Inactive
@mxzinke

mxzinke commented Oct 15, 2026

Copy link
Copy Markdown
Author

@richiemcilroy Anything open from your point of view? Can you help me finish this PR up?

@richiemcilroy

Copy link
Copy Markdown
Member

Thanks @mxzinke! Greptile is at 2/5 here. We only merge once Greptile reaches 5/5, so please address its findings in the summary above (or reply to them if you think one is wrong), then comment @greptileai review to re-run it. If the branch is behind main, please merge or rebase on main first. Once it is 5/5 we will run the full verification suite on it.

@vercel
vercel Bot temporarily deployed to Preview – cap-status October 18, 2026 17:08 Inactive
@mxzinke

mxzinke commented Oct 18, 2026

Copy link
Copy Markdown
Author

@greptileai review

@mxzinke

mxzinke commented Oct 18, 2026

Copy link
Copy Markdown
Author

@richiemcilroy Ready for review! Greptile 5/5

This branch was previously deployed

1 inactive deployment
Preview – cap-status — 806a669f Deployed Oct 18, 2026 by vercel[bot]
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.

2 participants