Skip to content

Add comprehensive SSO provider support with email confirmation - #900

Open
aXenDeveloper wants to merge 2 commits into
canaryfrom
claude/sso-built-in-providers
Open

aXenDeveloper wants to merge 2 commits 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

…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 with a one-time
  code before an account is created or linked.
- 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.

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>
Claude-Session: https://claude.ai/code/session_01S9WHKDMZd6SGLUjdYbi4hT
@github-actions

Copy link
Copy Markdown

Hey there and thank you for opening this pull request! 👋🏼

We require pull request titles to follow the Conventional Commits specification and it looks like your proposed title needs to be adjusted.

Details:

No release type found in pull request title "Add comprehensive SSO provider support with email confirmation". Add a prefix to indicate what kind of release this pull request corresponds to. For reference, see https://www.conventionalcommits.org/

Available types:
 - feat: A new feature
 - fix: A bug fix
 - docs: Documentation only changes
 - style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
 - refactor: A code change that neither fixes a bug nor adds a feature
 - perf: A code change that improves performance
 - test: Adding missing tests or correcting existing tests
 - build: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
 - ci: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
 - chore: Other changes that don't modify src or test files
 - revert: Reverts a previous commit

@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-24T08:44:02.732406Z 53b551f 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 53b551f.

@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 👍 / 👎.

…ogos

- Replace the six-digit code with an emailed confirmation link, matching
  VitNode's existing email verification. 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.
- Rework the pending table (confirmHash/confirmExpiresAt/...) and
  regenerate the unreleased migration.
- Reddit and GitLab become 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.
- Center the "Check your email" state, add a mail icon to the email input
  and icons to "Send a new link" and "Use a different email".
- Update docs and screenshots for the link flow.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01S9WHKDMZd6SGLUjdYbi4hT

This branch has not been deployed

No deployments
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