Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Admin extensions preflight authentication #1420

Open
tamir-boaideas opened this issue Aug 25, 2024 · 2 comments · May be fixed by #1436
Open

Admin extensions preflight authentication #1420

tamir-boaideas opened this issue Aug 25, 2024 · 2 comments · May be fixed by #1436
Labels
good first issue Good for newcomers Stale

Comments

@tamir-boaideas
Copy link

tamir-boaideas commented Aug 25, 2024

Issue summary

According to the docs, I should be able to make authenticated api calls the extension (which runs in the frontend) to my app's backend (which runs on the same domain as app_url).
The app uses the Express.js template

I have an admin action extension that makes the following API call:

Image

The route is guarded by the validateAuthenticatedSession middleware and allowed the cors configurations as the docs requires.

Image

  • @shopify/* package and version: @shopify/shopify-app-express version 5.0.3
  • Node version: 20.17.0
  • Operating system: MacOS

Expected behavior

The fetch request should pass the authentication.

Actual behavior

The request's preflight redirects to /api/auth (meaning it didn't authenticated currectly) which fails because of cors (but would fail regardless)

This is the preflight

Image

This is the "real" request which fails because of cors (due to the preflight failing). As you can see, the header is there, but it can't pass the validateAuthenticatedSession middleware

Image

If I disable the middleware everything works but the fetch call must be authenticated so I can't allow it.

I reached out to the partners support and they contacted the team who confirmed that they can see the middleware throwing a 403 but can't tell why. They suggested to rebuild the logic with an Admin action extension as I did and showed here but it didn't solve the issue.

@paulomarg
Copy link
Contributor

paulomarg commented Aug 27, 2024

Hi, thanks for raising this. I think you're right, and we're not handling OPTIONS requests properly in that package - we should be just setting the CORS headers and responding in that case, instead of trying to authenticate it.

I'll add this to our tracking and we'll look into it!

@paulomarg paulomarg added the good first issue Good for newcomers label Aug 27, 2024
@admirsaheta admirsaheta linked a pull request Aug 29, 2024 that will close this issue
6 tasks
Copy link
Contributor

We're labeling this issue as stale because there hasn't been any activity on it for 60 days. While the issue will stay open and we hope to resolve it, this helps us prioritize community requests.

You can add a comment to remove the label if it's still relevant, and we can re-evaluate it.

@github-actions github-actions bot added the Stale label Oct 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers Stale
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants