Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Auth callback should throw 403 if CookieNotFound occured to handle OAuth retries #110

Closed
2 tasks done
kazukinagata opened this issue Jul 1, 2021 · 1 comment
Closed
2 tasks done

Comments

@kazukinagata
Copy link

Overview/summary

When validateAuthCallback called, shopify-api will throw a CookieNotFound error if sessionCookie has been expired.
In the scenario, koa should throw 403 instead of 500 to handle retrying OAuth process.

catch (e) {
        switch (true) {
          case (e instanceof Shopify.Errors.InvalidOAuthError):
            ctx.throw(400, e.message);
            break;
          case (e instanceof Shopify.Errors.SessionNotFound):
          case (e instanceof Shopify.Errors.CookieNotFound): // Add here
            ctx.throw(403, e.message);
            break;
          default:
            ctx.throw(500, e.message);
            break;
       }
}

case (e instanceof Shopify.Errors.SessionNotFound):

Motivation

You know the OAuth process has a limit of 60s to be completed, and it will expire the sessionCookie after that point.
Shopify testers sometimes wait 60s before continuing the OAuth process then cause Internal Server Error.
In order to pass the test, we need to handle OAuth retries, but with a 500 error, error handling is difficult.

Related issue: Shopify/shopify-api-js#130 (comment)


Checklist

  • Please delete the labels section before submitting your issue
  • I have described this enhancement in a way that is actionable (if possible)
@kazukinagata kazukinagata changed the title Auth callback should throw 403 if CookieNotFound error occured to handle retry OAuth Auth callback should throw 403 if CookieNotFound error occured to handle OAuth retries Jul 1, 2021
@kazukinagata kazukinagata changed the title Auth callback should throw 403 if CookieNotFound error occured to handle OAuth retries Auth callback should throw 403 if CookieNotFound occured to handle OAuth retries Jul 1, 2021
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jan 30, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jan 30, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jan 30, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jan 30, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jan 30, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jan 30, 2023
@github-actions
Copy link

Note that this repo is no longer maintained and this issue will not be reviewed. Prefer the official JavaScript API library. If you still want to use Koa, see simple-koa-shopify-auth for a potential community solution.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants