8000 fix: include XSRF tokens in same-origin SSE requests by Pioneer-Weirdo · Pull Request #543 · google/adk-web · GitHub
[go: up one dir, main page]

Skip to content

fix: include XSRF tokens in same-origin SSE requests - #543

Open
Pioneer-Weirdo wants to merge 1 commit into
google:mainfrom
Pioneer-Weirdo:codex/fix-adk-web-sse-xsrf
Open

Pioneer-Weirdo wants to merge 1 commit into
google:mainfrom
Pioneer-Weirdo:codex/fix-adk-web-sse-xsrf

Conversation

@Pioneer-Weirdo
Copy link
Copy Markdown

When the backend requires an XSRF cookie/header pair, streaming requests to /run_sse omit X-XSRF-TOKEN because native fetch bypasses Angular's HttpClient interceptor. Ordinary API requests already include it.

Read the token through HttpXsrfTokenExtractor for each subscription and attach the default header to same-origin streaming requests. Resolve URLs against the document base URL and compare origins so external hosts, schemes, and ports do not receive the page's token. Add regression coverage for URL forms, cookie changes, absent and encoded cookies, invalid URLs, and cancellation.

Fixes #459.

Validated on Windows with Node 24.19.0, Angular 21.2.22, and Chrome 154 after installing the committed lockfile with npm ci:

  • Full suite: node node_modules/@angular/cli/bin/ng.js test agent_framework_web --watch=false --browsers=ChromeHeadlessCI --progress=false — 840 passed, 37 existing skips, 0 failures.
  • Production build: node node_modules/@angular/cli/bin/ng.js build agent_framework_web --configuration=production --progress=false — passed.

The regression was reproduced before the fix: an ordinary same-origin HttpClient POST included the token, while the streaming POST omitted it. Backend end-to-end validation was not performed.

@google-cla
google-cla Bot commented Oct 9, 2026
Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

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.

Unauthorized runSSE requests when XSRF protection enabled

1 participant

0