Skip to content

Preserve Google OAuth state during analytics requests - #96

Merged
philipithomas merged 1 commit into
mainfrom
fix/google-login-followup-20261012
Oct 12, 2026
Merged

philipithomas merged 1 commit into
mainfrom
fix/google-login-followup-20261012

Conversation

@philipithomas

@philipithomas philipithomas commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Google sign-in can fail with csrf_detected when a delayed Ahoy response overwrites the newer Rails session cookie containing the OAuth state. The sign-in button generates analytics requests, and resolving current_account loads the older session and causes it to be written back. This was reproduced against production using separate cookie jars to deliver the stale analytics response after the authorization redirect.

Make Ahoy's API controllers skip session persistence while retaining session reads for account attribution. Apply the callback before Ahoy's own filters, including early responses. Google state validation remains enabled.

Regression coverage exercises the real Rails cookie middleware and Google request/callback flow, verifies that incorrect state is still rejected, and checks that events and visits preserve signed-in account attribution without replacing the session cookie. Synthetic Google credentials are configured only in the test environment; tests do not contact Google.

Validation:

  • The regression fails without the fix: the valid-state callback reports Csrf detected, and signed-in analytics replaces the session cookie.
  • Integration and Google strategy tests: 12 tests, 75 assertions passed in both modes.
  • Tests ran in disposable containers with an isolated test database and outbound network access disabled.
  • Full CI passed: SOLO 237 tests / 1,763 assertions; MULTIUSER 245 tests / 1,827 assertions, with no failures, errors, or skips.
  • Zeitwerk, browser generation, Brakeman, dependency audit, and production Docker boot/homepage/cache checks passed.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 12, 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-12T11:18:03.992119Z 8f35bf6 PR opened
ℹ️ 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.

@philipithomas
philipithomas merged commit 70063cd into main Oct 12, 2026
3 checks passed
@philipithomas
philipithomas deleted the fix/google-login-followup-20261012 branch October 12, 2026 11:29
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.

1 participant