Repository navigation
Fix Pages and Workers static asset uploads in Code Mode - #439
Draft
irvinebroque wants to merge 2 commits into
Draft
irvinebroque wants to merge 2 commits into
irvinebroque wants to merge 2 commits into
Conversation
Pages Direct Upload and Workers static assets need a short-lived JWT as the bearer on the asset endpoints. execute always sent the session's token, so every upload failed with 403 (8000013). Forward the code's bearer only on the four asset upload POSTs, and only when it is an unexpired JWT other than the session token.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pages Direct Upload and Workers static asset uploads can mint an upload JWT in Code Mode, but the upload fails even when the caller sends the right token.
GlobalOutboundreplaces it with the MCP connection token. Fixing credential selection at that shared boundary covers bothcloudflare.request()and nativefetch()without changing either caller API.flowchart TD subgraph before[Before] direction LR B1["Mint upload JWT with MCP token"] --> B2["Caller sends upload JWT"] B2 --> B3["Proxy replaces it with MCP token"] B3 --> B4["Upload API rejects the request"] end subgraph after[After] direction LR A1["Mint upload JWT with MCP token"] --> A2["Caller sends upload JWT"] A2 --> A3["Proxy sends only the upload JWT"] A3 --> A4["Upload succeeds; finalize with MCP token"] endSame caller code (Workers multipart upload):
What changes on the wire:
POST /client/v4/accounts/{account_id}/workers/assets/upload?base64=true -Authorization: Bearer <MCP connection token> +Authorization: Bearer <upload JWT>The proxy checks the configured API origin and base path first. Only the three Pages asset POSTs (
check-missing,upload,upsert-hashes) and the Workers asset upload POST can use the upload JWT. If it is missing, malformed, or stale beyond the clock-skew allowance, the proxy stops before sending the request. The upload API still verifies the JWT signature and scope. Uploads aren’t redirected or replayed after a transport failure, and upload-token denials don’t trigger an MCP OAuth scope prompt. Everything else, including minting the JWT and finalizing the deployment, still uses the MCP connection token.Builds on #429 by @acoyfellow; the draft retains the original contribution and adds the fail-closed credential handling on top.
Fixes #386. Fixes #389.