Skip to content

feat: GCS-backed auth state persistence for Cloud Run#9

Merged
5queezer merged 15 commits intomainfrom
feature/7-gcs-auth-storage
Mar 21, 2026
Merged

feat: GCS-backed auth state persistence for Cloud Run#9
5queezer merged 15 commits intomainfrom
feature/7-gcs-auth-storage

Conversation

@5queezer
Copy link
Copy Markdown
Owner

Summary

  • Add pluggable StorageBackend protocol with LocalBackend (no-op) and GCSBackend implementations
  • Persist cookies.json + source-state.json to GCS so Cloud Run cold starts can restore LinkedIn session state
  • Hook into startup (download), post-login (upload), shutdown (upload), and logout (delete) lifecycle points
  • Add [gcs] optional dependency (pip install linkedin-scraper-mcp[gcs])

Configuration

AUTH_STORAGE_BACKEND=gcs
AUTH_STORAGE_GCS_BUCKET=my-bucket
AUTH_STORAGE_GCS_PREFIX=linkedin-mcp    # optional
AUTH_STORAGE_USERNAME=williamhgates

Design

See docs/design-gcs-auth-storage.md for the full design doc with decision log.

Only portable artifacts are persisted (~KB), not the full browser profile. Cloud Run always runs as a foreign runtime and bridges from cookies on every cold start.

Test plan

  • 15 new unit tests with InMemoryBackend and FailingBackend test doubles
  • sync_from_remote raises StorageSyncError on download failure
  • sync_to_remote logs warning but doesn't crash on upload failure
  • delete_remote returns False on failure
  • Config validation rejects incomplete GCS config
  • All 354 existing tests pass with no regressions
  • Manual: deploy to Cloud Run, verify cold start restores session from GCS

Closes #7

Generated with Claude Opus 4.6 (1M context).

Prompt: how to solve https://github.com/5queezer/linkedin-mcp-server/issues/7 → brainstorming → plan → subagent-driven implementation

🤖 Generated with Claude Code

5queezer and others added 12 commits March 20, 2026 22:39
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Guard against None bucket in get_storage_backend()
- Replace assert with `or ""` fallback for username type narrowing
- Skip storage sync when OAuth is enabled (no cookie auth needed)
- Add missing delete_remote failure test

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@5queezer
Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

5queezer and others added 3 commits March 21, 2026 00:37
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Cloud Run needs both: OAuth protects the MCP endpoint, AND cookie-based
auth is needed for LinkedIn scraping. The storage sync must run
regardless of OAuth mode.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
When AUTH_STORAGE_BACKEND=gcs, only cookies.json and source-state.json
are synced — the Chromium profile directory doesn't exist locally.
Relax the startup check to only require source state + cookies when
remote storage is configured, since Cloud Run always bridges from
cookies as a foreign runtime.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@5queezer 5queezer merged commit ebbbe94 into main Mar 21, 2026
2 checks passed
@5queezer 5queezer deleted the feature/7-gcs-auth-storage branch March 21, 2026 15:03
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.

[BUG] Replace cookie-based auth with OAuth2 + persistent session storage

1 participant