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

fix: same site api call with session cookie #8434

Closed
wants to merge 1 commit into from

Conversation

gastonfournier
Copy link
Contributor

@gastonfournier gastonfournier commented Oct 11, 2024

About the changes

When a web app is hosted in the same domain as Unleash UI and the web app uses unleash SDK to make requests to Unleash, the browser automatically includes the cookie in the request headers if:

- The request URL matches the cookie's Path attribute (which it does in this case).
- The request is sent to the same domain (which it is, since both apps are under the same domain).

This PR aims to limit the scope of unleashSession for those URLs that are not APIs. This is an alternative to #8435

Closes #8029

Copy link

vercel bot commented Oct 11, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
unleash-monorepo-frontend ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 11, 2024 3:45pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
unleash-docs ⬜️ Ignored (Inspect) Oct 11, 2024 3:45pm

Copy link
Contributor

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails

Scanned Manifest Files

@gastonfournier
Copy link
Contributor Author

Close in favor of #8435

gastonfournier added a commit that referenced this pull request Oct 15, 2024
## About the changes
This fixes #8029. How to reproduce the issue is in the ticket.

The issue happens because when a web app is hosted in the same domain as
Unleash UI and the web app uses unleash SDK to make requests to Unleash,
the browser automatically includes the cookie in the request headers,
because:

- The request URL matches the cookie's Path attribute (which it does in
this case).
- The request is sent to the same domain (which it is, since both apps
are under the same domain).

And this is by design in the HTTP cookie specification:
https://datatracker.ietf.org/doc/html/rfc6265

This PR avoids overriding the API user with the session user if there's
already an API user in the request. It's an alternative to
#8434

Closes #8029
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Unleash-Session Cookie Sent In Headers
1 participant