Skip to content

Canonicalise local browser origin for Google OAuth - #322

Merged
witbrock merged 1 commit into
mainfrom
codex/local-loopback-canonicalisation
Jul 28, 2026
Merged

witbrock merged 1 commit into
mainfrom
codex/local-loopback-canonicalisation

Conversation

@witbrock

Copy link
Copy Markdown
Member

What changed

  • Redirect only local browser entry GET/HEAD requests from 127.0.0.1 to the explicitly configured localhost Google OAuth origin on the same port.
  • Preserve paths and query strings and mark the temporary redirect no-store.
  • Keep health checks, APIs, static resources, POST requests, other ports, and hosted configurations unchanged.
  • Make the direct Python launcher open localhost when Flask binds to 127.0.0.1.

Why

Google OAuth requires the supplied redirect URI to match the registered URI exactly. Von's local callbacks are configured for localhost, while direct startup could open the UI on 127.0.0.1; those are different browser origins and break the OAuth popup/session path.

Validation

  • 69 focused pytest cases passed across local canonicalisation, Google login OAuth, agent Gmail OAuth, launcher behaviour, and health-path regressions.
  • Ruff lint, Pyright, and git diff --check passed.
  • Live HTTP validation confirmed the UI entry returns 302 to the exact localhost path/query while /health and auth-status remain 200 on 127.0.0.1.
  • Browser validation confirmed the address bar lands on http://localhost:5099/... and renders the canonical page.

Copilot AI review requested due to automatic review settings July 28, 2026 14:37

Copilot AI 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.

Pull request overview

This PR ensures local Von UI navigation uses a single, Google OAuth-compatible browser origin by canonicalising 127.0.0.1 entry requests to the configured localhost origin (same port), preventing OAuth redirect URI mismatches during local development.

Changes:

  • Add a Flask before_request hook that redirects only UI entry GET/HEAD requests from 127.0.0.1:<port> to http://localhost:<port>, preserving path/query and setting Cache-Control: no-store.
  • Introduce build_browser_entry_url() and update the direct Python launcher to open localhost when binding to 127.0.0.1.
  • Add focused pytest coverage for redirect/canonicalisation behaviour and launcher URL building.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
tests/backend/test_local_browser_origin_canonicalisation.py Adds test coverage for local origin canonicalisation rules and app-factory installation.
src/workflows/von/main.py Updates browser auto-open URL to use the canonicalised entry URL helper.
src/backend/server/utils_flask.py Implements local browser origin canonicalisation middleware and the entry URL builder.

Comment on lines +2262 to +2266
"/",
"/von",
"/von/",
"/von/workflow-studio",
}
@witbrock
witbrock marked this pull request as ready for review July 28, 2026 21:26
@witbrock
witbrock merged commit 6b32d7a into main Jul 28, 2026
5 checks passed
@witbrock
witbrock deleted the codex/local-loopback-canonicalisation branch August 3, 2026 11:58
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