Patch JwtPayload in order to correctly parse Checkout UI extensions session tokens #1346
+3
−3
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.
Checkout UI session tokens are actually missing "iss" and "sid" keys (see: https://shopify.dev/docs/api/checkout-ui-extensions/2024-10/apis/session-token). The current implementation makes them mandatory, generating exceptions while verifying JWT tokens (see the new
ShopifyApp::WithShopifyIdToken
concern, and the legacyShopifyApp::JWTMiddleware
middleware).Description
The PR is for:
ShopifyAPI::Auth::JwtPayload
constructor (line 30) when the JWT Token is missing the "iss" and "sid" keys (both optional in Checkout UI session tokens)ShopifyApp
engine fails, raising an obscure exceptionshopify_user_id
from the "sid" key, even when it's formatted asgid://shopify/Customer/<customerId>
How has this been tested?
Develop a basic frontend Checkout UI extension and make cors authenticated calls to a Rails backend developed using
shopify_app
gem (v22.4). Any request fails without reaching the corresponding controller, since an exception is raised in theShopifyApp::JWTMiddleware
middleware injected by theShopifyApp
engine (seeengine.rb
, row 20).After applying the patch, requests are nomally executed without raising any exception.
Checklist: