Shopify / Shopify/shopify-app-template-php

APP_UNINSTALLED session deletion process

Open
#481 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
340
Forks
108
PR merge metrics
No merged PRs in 30d

Description

Hello,

I use shopify-app-template-php for the development of my application and I encountered several failed reviews without really understanding why.
The problem was that my application was not redirecting to oauth directly on each uninstallation / new installation.

It turns out that I relied on the APP_UNINSTALLED hook to delete the user's session.
php/blob/f3d8e9fe0dee30d941eea330dfb06e2f818c01b5/web/app/Lib/Handlers/AppUninstalled.php#L15

But the problem is that the hook can be called directly after uninstallation (very good) but also 5 minutes later, so if we reinstall the application and the hook has not been triggered we will have an a review error (because the application will not redirect to oauth as the session is still in database) and we will have an invalid access_token.
EnsureShopifySession throws errors on autorization headers if we use only php code and no ajax/xmlrequest

The major problem is that the session can be deleted at any time, cause of the hook delevry time

Even after the user has reinstalled the application, his session can be deleted because of the previous hook which will be triggered too late

Perhaps an enhancement of this part, could be a good point for new shopify developper.

Tested on php8.1 linux platform
The app contains only php and no modern javascript app (react, etc...)

Ps : Sorry for my bad english

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with web/app/Lib/Handlers/AppUninstalled.php at the linked line and trace how the APP_UNINSTALLED hook removes sessions. Reproduce a delayed uninstall hook after reinstalling the app, then verify that the earlier hook cannot remove the newer session or leave an invalid access token.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
authentication
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.