Shopify / Shopify/shopify-api-php
Default cookie setter in OAuth is not setting samesite = None
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 473
- Forks
- 193
- Avg merge
- 5h 8m
- Merged PRs (30d)
- 1
Description
Issue summary
The samesite parameter is being ommited from setcookie function in OAuth2 process: https://github.com/Shopify/shopify-api-php/blob/main/src/Auth/OAuth.php#L351, causing the default Lax mode to be selected.
This causes "Perform Token Exchange" step in https://shopify.dev/docs/apps/build/authentication-authorization/session-tokens#request-flow-using-a-session-token to fail when embedded page is loaded through an iframe (for example from Shopify admin panel), because the cookies will not be saved.
Expected behavior
The cookies should be set and OAuth should succeed in Shopify admin panel.
Actual behavior
The cookies are not set and OAuth fails in Shopify admin panel.
Steps to reproduce the problem
- Implement minimal application implementing Shopify's OAuth2 authentication (online mode = true), using this library, with default cookie setter.
- Install application into any Shopify store.
- Delete the initial customer's session. (Simulating different admin user or expired session).
- Try to perform "Token Exchange" from Shopify admin panel.
Reduced test case
Checklist
- I have described this issue in a way that is actionable (if possible)
- I have created a merge request fixing this issue.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Inspect src/Auth/OAuth.php around line 351, where the OAuth cookie is set, and review the cookie behavior involved in embedded Shopify admin flows. Reproduce the online-mode token exchange with an iframe or add a focused test if the repository provides one; done means the cookies are saved and OAuth succeeds in the Shopify admin panel.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- authentication
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100