Repository navigation
feat(auth): GitHub and Google social login with admin controls - #165
Merged
Merged
Conversation
Adds server-side authorization-code social login for GitHub (OAuth) and Google (OIDC) alongside the existing Entra SAML SSO and password login. Server: - New core/sso/social module: provider drivers (GitHub OAuth, Google OIDC via openid-client with id_token signature/issuer/audience/expiry/nonce validation), single-use browser-bound state in Redis (GETDEL, 10 min TTL, workspace+provider+operation bound), PKCE S256 for Google. - Identity resolution by stable provider ids (GitHub user id, Google sub); no silent email-match linking. Signup only with provider-verified email, allowSignup enabled, and workspace domain allowlist respected; cloud mode requires an invitation. Provider tokens are discarded after identity resolution. - Login completes through the normal session path including MFA challenge (mfa token handed over via URL fragment) and MFA-setup enforcement, not the SAML direct-cookie shortcut. - Account connect flow in account settings requires a recent sign-in (JWT iat within 10 minutes); link collisions and cross-workspace states are rejected; DB unique index backs concurrent-callback safety. - Enforced SAML SSO blocks social login in start/callback/link paths and social providers no longer satisfy the "at least one active SSO provider" requirement for enabling enforcement. - Provider admin reuses /sso endpoints: one GitHub and one Google config per workspace (DB-enforced), secrets encrypted with AppSecretCryptoService, only a hasClientSecret boolean and exact callback URL exposed; secrets never appear in API responses, logs, or audit payloads. - Audit events for provider config changes, identity link/unlink, successful social logins (with actor), and safe login-failure records. Client: - "Continue with GitHub/Google" buttons on the login page, shown only for enabled providers and hidden when SSO is enforced; translated error notifications for callback failures. - Security settings: per-provider cards (client id, write-only secret, enable, allow sign-ups, copyable callback URL). - Account settings: connected accounts with connect/disconnect. - MFA challenge accepts a token handed over via URL fragment. Migration 20261123T120000 adds partial unique indexes (one social provider per workspace type; one account per provider identity per workspace). Tests: unit specs for the service, both drivers, and provider management; opt-in integration spec runs the real controller flow against PostgreSQL and Redis with mocked provider endpoints; full jest suite green. Docs: docs/SOCIAL_LOGIN_SETUP.md. Signed-off-by: Leo Stehlik <[email protected]>
Signed-off-by: Leo Stehlik <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Behavior
Adds GitHub OAuth and Google OIDC login alongside password login and Entra SAML. Administrators configure and enable each provider independently in workspace Security settings; both start disabled and signup defaults off. Members can explicitly connect identities in account settings. Existing accounts are never silently linked by matching email.
AppSecretCryptoService; provider responses expose configured status and callback URL, never the stored secret. Configuration and identity changes are audited with workspace/provider attribution.Migration and setup
20261123T120000-social-auth-providers.tsadds partial unique indexes for one configuration per workspace/provider and one active owner per provider identity. The review fixes require no additional migration or database reset. Existing content and volumes must be preserved.Setup and test instructions cover both OAuth registrations. Register the exact callback shown in the UI:
https://<host>/api/auth/social/github/callbackhttps://<host>/api/auth/social/google/callbackFor a shared live test, use an HTTPS hostname accepted by both providers and matching the configured application URL. Google does not accept an arbitrary private HTTP hostname; localhost has separate development exceptions.
Verification
pnpm --filter server exec jest --runInBand: 298 passed, 13 opt-in database tests skipped in this invocation. Includes existing password/SAML regressions, real Nest/Fastify HTTP cookie and JWT-guard tests, and Google token validation through the actual OIDC library against local token/JWKS endpoints with signed synthetic tokens.WRENLORE_SOCIAL_TEST=disposable SOCIAL_INTEGRATION_DB=... SOCIAL_INTEGRATION_REDIS=... node scripts/social-ci.cjs: 13 passed against isolated PostgreSQL 18 + Redis, including reconnects, active-link protection and concurrent identity claims. Provider endpoints are mocked.node scripts/social-ui.cjs: Chromium passes fresh-browser MFA, refresh/submission/cleanup, stale/missing-token handling and SAML account-link controls. Uses real components with mocked application API responses.pnpm --filter server buildandpnpm --filter client build: pass.node scripts/history-ui.cjsandnode scripts/history-ui.cjs --full-editor: pass locally in Chromium and WebKit, including desktop/short/mobile history controls and full-editor rendering./api/health: pass against disposable PostgreSQL/Redis.Live provider verification remains outstanding: no real GitHub/Google account authorization has been performed. It requires registered OAuth client IDs/secrets and the chosen callback hostname. Mock endpoints and signed synthetic tokens establish protocol handling, not a completed live-provider rollout.
Leave merge, deployment and release pending joint review. Production has not been changed.