[4.x] Add token-based security for cart loading#4207
Draft
lukeholder wants to merge 4 commits into4.xfrom
Draft
Conversation
Member
lukeholder
commented
Jan 21, 2026
- Require valid token or logged-in cart owner to load a cart via load-cart action
- Add cartLinkExpiry setting (default 24 hours) for token expiration
- Add getLoadCartUrl() method to Carts service that generates secure token URLs
- Update Order::getLoadCartUrl() to return secure token URL
- Add email challenge flow for cart recovery when token is missing/expired
- Register commerce_cart_recovery system message for recovery emails
- Add _cart/email-challenge.twig and email-sent.twig templates
- Carts that have no email/custom associated and not address information will load without needing to check token etc.
- Add secure token validation to load-cart action - Carts with email/addresses require valid token or owner authentication - Carts without sensitive data can load without token - Add email challenge flow for unauthenticated cart recovery - Register commerce_cart_recovery system message for recovery emails - Add cartLinkExpiry setting (default 24 hours) - Add getLoadCartUrl() to Carts service for generating secure URLs
|
Take a look at _getCart() in CartController.php as well because it is called by actionUpdateCart() and actionComplete() and any other cart modification actions, make sure the same validation is applied. I am not sure how this will affect the over all functionality, but from a cryptographic standpoint, for the generateCartNumber, I would move to something like bin2hex(random_bytes(16)). |
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.