Repository navigation
execute: send the upload JWT to the asset upload endpoints - #429
Open
acoyfellow wants to merge 4 commits into
Open
acoyfellow wants to merge 4 commits into
acoyfellow wants to merge 4 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.
# Conflicts: # src/tools/execute.ts
Contributor
Author
|
Updated to include #439 (@irvinebroque's fail-closed handling, cherry-picked) plus one fix found testing it live on staging: Workers |
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.
executereplaced the upload JWT with the MCP session token on the static asset upload endpoints, which only accept the upload JWT. Pages direct upload failed atcheck-missingwith403 8000013 Authorization failed, and Workers asset uploads could not work. Fixes #386. Fixes #389.What changed
/pages/assets/check-missing,/pages/assets/upload,/pages/assets/upsert-hashes,/accounts/{id}/workers/assets/upload). Everything else keeps the session token.assets-upload-sessionreturns a JWT prefixedcfwau_(cfwau_eyJ...). Fix Pages and Workers static asset uploads in Code Mode #439's check decodedcfwau_eyJ...as the header and refused the real token, so Workers uploads were still blocked. One optionalcfwau_prefix is now stripped before the check; the token is sent unchanged.Proof (staging,
execute)Before (main):
With #439 only (d22ac98):
This PR (d5618a5):
Reproduce
In
executeagainst staging:GET .../pages/projects/<name>/upload-token, thenPOST /pages/assets/check-missingwithAuthorization: Bearer <jwt>.POST .../workers/scripts/<name>/assets-upload-session, thenPOST /accounts/<id>/workers/assets/upload?base64=truewithAuthorization: Bearer <result.jwt>.Tests
tests/asset-upload-token.test.ts: acfwau_JWT is kept with its prefix (fails before the fix).tests/execute-requests.test.ts: the Workers flow's session returns acfwau_JWT and the upload carriesBearer cfwau_...(fails before the fix).tests/scope-challenge.test.ts: the Workers upload path uses an account ID, not a zone ID.