Skip to content

feat: Add comprehensive SSO provider support with email confirmation - #900

Merged
aXenDeveloper merged 1 commit into
canaryfrom
claude/sso-built-in-providers
Oct 30, 2026
Merged

aXenDeveloper merged 1 commit into
canaryfrom
claude/sso-built-in-providers

Conversation

@aXenDeveloper

Copy link
Copy Markdown
Owner

Description

What?

This PR adds support for 12 new SSO providers (Apple, Microsoft, GitLab, PayPal, Reddit, Slack, TikTok, Twitch, Twitter/X, LinkedIn, Atlassian, and Kick) with a complete refactor of the SSO authentication flow. Key changes include:

  • New SSO Protocol Library (sso-protocol.ts): Centralized utilities for PKCE, JWT verification, secret hashing, and timing-safe comparisons
  • SSO Flow Store (sso-flow-store.ts): Database-backed storage for OAuth state and pending operations with automatic cleanup
  • Email Confirmation Flow: New UI and API routes for providers that don't share verified emails (Reddit, TikTok, Kick)
  • Provider Adapters: Individual adapter implementations for each new provider with standardized interfaces
  • Database Migration: New tables core_sso_attempts and core_sso_pending to track OAuth flows securely
  • Comprehensive Documentation: Setup guides for each provider with environment variable requirements
  • Enhanced Security: PKCE support, timing-safe comparisons, and secure state/nonce handling

Why?

The previous SSO implementation was limited to 3 providers (Google, Discord, Facebook) with a basic OAuth flow. This expansion:

  1. Increases user choice by supporting 12 additional popular platforms
  2. Improves security with PKCE, proper JWT verification, and secure state management
  3. Handles edge cases like providers without verified emails through email confirmation
  4. Provides better maintainability with standardized adapter patterns and centralized protocol logic
  5. Enables self-hosted instances to use providers like GitLab and Atlassian

The refactored flow separates concerns: protocol handling, provider-specific logic, and UI flows are now cleanly isolated.

Test Plan

  • Added comprehensive unit tests for sso-protocol.ts covering PKCE, JWT verification, and secret hashing
  • Added extensive provider adapter tests (providers.test.ts) covering token exchange, user info retrieval, and error handling for all 12 providers
  • Added tests for sso-flow-store.ts covering state/nonce validation and cleanup
  • Added tests for email confirmation flow and form post handling
  • Existing SSO callback tests updated to cover new error codes and email confirmation paths
  • All tests pass with the new implementation

https://claude.ai/code/session_01S9WHKDMZd6SGLUjdYbi4hT

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-30T16:18:28.503170Z d299f04 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

React Doctor found no new issues. 🎉

Reviewed by React Doctor for commit d299f04.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0d77f3950e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +147 to +150
const pending = await this.sso.flowStore.consumePending({
now,
tokenHash,
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Consume only the pending email whose code was verified

If an email-change request runs concurrently with code verification after the resend cooldown, countCodeAttempt() can return the code hash for address A, then setPendingCode() can replace the stored email and hash with address B before consumePending() runs. The old code passes verification, but the subsequent delete returns address B, which is then passed to signUpOrOfferLink() as verified. This allows a visitor who controls A to create an email-verified account for an unowned address B. Make consumption conditional on the exact code hash and email that were checked, or perform verification and consumption under a transaction with row locking.

Useful? React with 👍 / 👎.

@aXenDeveloper
aXenDeveloper force-pushed the claude/sso-built-in-providers branch from 53b551f to fc7cc1b Compare October 30, 2026 15:39
@aXenDeveloper aXenDeveloper changed the title Add comprehensive SSO provider support with email confirmation feat: Add comprehensive SSO provider support with email confirmation Oct 30, 2026
@github-actions github-actions Bot added the 💡 Feature A new feature label Oct 30, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fc7cc1b1d4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +187 to +192
<SSOCallbackContent
errorActions={errorActions}
onLink={linkSso}
providerId={providerId}
providers={ssoProvidersOf(config)}
showResetPassword={authMethodsOf(config).resetPassword}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Pass password-reset actions into the email-confirmation screen

When a confirmed address belongs to an existing account, this screen renders the link form without onRequestReset, even though showResetPassword can be true. SSOLinkFormContent gates both password recovery and setting an initial password on usePasswordReset().canRequest, which is false without that callback. Consequently, users who forgot their password or have a passwordless account cannot use the recovery flow offered by the normal SSO callback screen. Pass requestPasswordResetAction and config.captcha here as well.

Useful? React with 👍 / 👎.

Comment on lines +167 to +169
>
{t("email_completion.start_again")}
</Button>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Add the required icons to the restart actions

The new invalid-confirmation screen renders a “start again” action without an icon; the expired-pending screen in sso-email-completion.tsx does the same. AGENTS.md explicitly requires a leading, aria-hidden lucide-react icon on every action button, including retry and sign-in actions, with an exception only for dismiss controls. Add an appropriate icon before both restart labels.

AGENTS.md reference: AGENTS.md:L83-L83

Useful? React with 👍 / 👎.

…confirmation

Adds Apple, Atlassian, GitLab, Kick, LinkedIn, Microsoft, PayPal, Reddit,
Slack, TikTok, Twitch and Twitter (X) adapters under
@vitnode/core/api/adapters/sso/*.

Shared changes:
- Sign-in state is a server-side, single-use attempt bound to the browser
  and provider, carrying a PKCE verifier and OIDC nonce.
- ID tokens are validated with jose (signature, alg, iss, aud, exp, nonce).
- Returning identities sign in by provider account id, without an email.
- Identities without a trusted email confirm an address through an emailed
  link before an account is created or linked. The link works for 30
  minutes, once, and only in the browser that started the sign-in
  (prevents account pre-hijacking); a link opened elsewhere explains why.
- Apple's form_post callback is turned into a same-URL GET by the Start
  middleware, without relaxing cookie or CSRF rules.
- Connecting a new account from Settings needs a sign-in within the hour.
- Migration adds core_sso_attempts, core_sso_pending and PKCE/nonce
  columns on core_users_sso_operations.

UI:
- Reddit and GitLab are neutral buttons with their colored mark, Kick
  uses its black and green, Slack gets its four-color logo, so no button
  label ends up dark-on-color.
- Centered "Check your email" state, a mail icon on the email input and
  icons on "Send a new link" and "Use a different email".

Docs: one guide per provider, an email confirmation page, and corrected
Discord, Google, Facebook, custom adapter and connected-accounts guides.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@aXenDeveloper
aXenDeveloper force-pushed the claude/sso-built-in-providers branch from e535e27 to d299f04 Compare October 30, 2026 16:17
@aXenDeveloper
aXenDeveloper merged commit f4b0caa into canary Oct 30, 2026
4 checks passed
@aXenDeveloper
aXenDeveloper deleted the claude/sso-built-in-providers branch October 30, 2026 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

💡 Feature A new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant