Skip to content

fix(auth): bind social login state to the issuing browser - #308

Merged
voidvec merged 4 commits into
masterfrom
fix/social-login-state
Nov 9, 2026
Merged

voidvec merged 4 commits into
masterfrom
fix/social-login-state

Conversation

@voidvec

@voidvec voidvec commented Nov 7, 2026 •

Copy link
Copy Markdown
Owner

Summary

Social login accepted provider codes without a browser-bound transaction. Require an allowed Origin, a binding cookie and one-time Redis state before any GitHub/Google/WeChat exchange or account write.

  • Add a separate identity state port/service and Redis compare-before-delete adapter (600-second TTL, bounded completion, no production memory fallback).
  • Initialize the browser cookie with 204, then issue a transaction with 200. Discovery retains an empty deprecated authorize_url. Exchange accepts JSON/form code + state and rejects query credentials.
  • Keep explicit per-state login/link context in the SPA, clear callback secrets before router creation, and use a credentialed client without bearer refresh/retry.
  • Validate callbacks at startup, align Google redirect resolution, redact adapter/fallback/Nginx logs, and synchronize OpenAPI, SDKs, API baseline, bilingual guides and the full-stack SDK example.

Breaking changes

Deploy the backend and user SPA together for the next MINOR. SDK callers must keep cookies, send Origin and submit body code/state; restart old in-flight flows. Disable social providers or roll forward if rollout fails. Stateless login is not a rollback option. No database migration, release or deployment is included.

Migration details: https://github.com/voidvec/fulla/blob/d0b79a0a0a1416459935c7b14abc0b734c76d819/docs/domains/social-login.md

Post-rebase validation

Rebased onto master 571dc29 (includes #306, #320; both api-baseline bumps converge on version 1.6.0). Follow-up commits: bilingual security-architecture now describes the enforced state binding (llms regenerated, mirror gate 50/50 local pass); oasdiff release-download retry (the prior 504 never ran the gate; the gate passes on the new head); GitHub fallback double-move fix (review finding). Preserve upstream consent synchronization, macOS 15, ccache, coverage hard gates and documentation changes. Merge both Unreleased changelog entries into one section. The zh-CN social guide retains upstream account/issuance/tier details and adds the complete bound-state protocol; provider instructions now explicitly require code/state, Origin and cookies. Regenerate LLM output with the current generator.

  • Bilingual mirror 50/50, tracked Markdown links, architecture/API-diff and double-move guards passed.
  • OpenAPI selftest, 138-route/136-doc/134-YAML governance check and schema validation passed; pinned oasdiff against the new master passed its ERR gate (intentional query-removal warnings remain).
  • Python SDK: 27 passed, 5 integration tests skipped.
  • Scope audit: 80 original PR paths unaffected by master are byte-identical. Authentication code, configurations, generated clients and test implementations are unchanged; only necessary document reconciliation differs. All upstream-only changes are preserved.
  • Full post-rebase compiler/frontend/sanitizer/coverage runs are delegated to the new-head CI. They are not claimed as completed local reruns.

Historical full validation (before this rebase)

The following complete local runs validated the original implementation before master advanced; they are retained as provenance and are not post-rebase results:

  • Linux GCC 13 Release full build; PostgreSQL 16 + Redis 7 and explicit memory configurations: 609/609 CTest entries each, including the complete Drogon binary and both out-of-process suites.
  • WITH_SOCIAL=OFF: build/link and real-server smoke; discovery empty, all social start/login routes return 404.
  • Changed C++ units checked with warnings as errors, including the SDK consumer; independent review findings closed.
  • User SPA: build, 48 unit tests, 151 Chromium cases (8 resource-timeout cases passed in isolated rerun); lint 0 errors / 117 warnings.
  • Python SDK 27 passed / 5 integration skipped; Go tests passed; TypeScript build + 20 tests passed. All three generator drift checks passed.
  • Preflight six gates, architecture, boolean-macro check, UI parity and runtime OpenAPI checks passed. oasdiff: 0 errors; intentional query-removal warnings and required-body exceptions documented.
  • Real user Nginx + TLS gateway: callback SPA 200, no-store/no-referrer/CSP, and no code/state canaries in access/error logs.

Type of change

  • Breaking change (security protocol tightening)

Checklist

  • Tests added/updated; relevant complete local suites passed
  • CHANGELOG breaking/security entries and migration notes
  • English and zh-CN docs, LLM docs regenerated
  • OpenAPI registrations/YAML/runtime JSON, route fingerprints and manifest synchronized
  • Existing error codes reused; Python/Go/TypeScript SDKs regenerated
  • Additive API baseline ratified without force; precise oasdiff exceptions justified

CI observation after rebase: Security, Client SDKs and main CI Static Checks passed on the new head. OpenAPI Governance is blocked before its breaking gate: downloading the pinned oasdiff release returned HTTP 504 on both the original attempt and one targeted job retry (run 42471505005). The local pinned-v1.29.1 ERR gate against the new master passed. Other full CI jobs remain in progress; no completed remote validation is implied.

@voidvec
voidvec force-pushed the fix/social-login-state branch from af5d6ae to d0b79a0 Compare November 8, 2026 10:27
@voidvec
voidvec force-pushed the fix/social-login-state branch from d0b79a0 to d62e3bb Compare November 9, 2026 05:01
@voidvec
voidvec marked this pull request as ready for review November 9, 2026 07:37
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-09T07:40:15.556386Z b6ab7f0 Draft marked ready
ℹ️ 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.

@voidvec
voidvec force-pushed the fix/social-login-state branch from b6ab7f0 to 591524c Compare November 9, 2026 08:07
Require an allowed Origin, binding cookie and one-time Redis transaction before GitHub, Google or WeChat code exchange. Keep login/link callback context, SDK contracts, startup wiring and credential-safe logging consistent.

Validation: 609/609 CTest entries pass under PostgreSQL and memory configurations; WITH_SOCIAL=OFF builds and returns 404 for social starts/logins; frontend and three SDK checks pass.
…orced state binding

#306 merged a documented limitation that social login lacked browser-bound
state; this PR implements the protection, so both language mirrors now
describe the enforced mechanism (204 cookie init, one-time 600 s state,
Origin + cookie + body credentials, atomic consumption) and llms-full.txt
is regenerated.
The gate on this PR never ran: the v1.29.1 release-asset download 504'd
after 11 s with no retry. Retry transient gateway errors before failing.
…allback

loginValidated() moves callback into callbackPtr on entry, but the
not-configured branch still called respond(req, std::move(callback), ...)
-- invoking an already-moved-from (empty) std::function. Pre-existing
shape relocated verbatim from login() by this PR; Google/WeChat siblings
check before the move. Review finding (minor, unreachable today: the
guard 404s unconfigured providers first).
@voidvec
voidvec force-pushed the fix/social-login-state branch from 591524c to 3666684 Compare November 9, 2026 08:28
@voidvec
voidvec merged commit a4041d8 into master Nov 9, 2026
19 checks passed
@voidvec
voidvec deleted the fix/social-login-state branch November 9, 2026 09:47
voidvec added a commit that referenced this pull request Nov 9, 2026
2026-11-09 retest: fine-grained PAT can merge PRs (#306/#319/#308 via
pr merge --rebase); reading branch-protection rules is the new 403.
Record the real merge blockers (draft flag, up-to-date requirement,
author-cannot-self-approve, auto-merge disabled), prefer close->reopen
over empty commits for CI retriggering (pull_request branch filter +
non-default edited event gotcha), and mark Automatically-delete-head-
branches as no longer effective (manual delete after merge).
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