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

No more cookies included in requests? #1133

Closed
sneko opened this issue Dec 25, 2019 · 10 comments
Closed

No more cookies included in requests? #1133

sneko opened this issue Dec 25, 2019 · 10 comments
Milestone

Comments

@sneko
Copy link

sneko commented Dec 25, 2019

Describe the bug

Hi @imolorhe , it's been some time without using Altair but I noticed I'm not anymore able to send requests since they no longer includes my credential cookies. I opened the Chrome console to check and I cannot see them even if the request is made to a domain having some cookies in place.

Did you make some changes about that?

Thank you,

Desktop (please complete the following information):

  • MacOS
  • Chrome
  • 2.4.2
@welcome
Copy link

welcome bot commented Dec 25, 2019

👋🏾Thanks for opening your first issue here! Be sure to follow the issue template! ✌🏾

@imolorhe
Copy link
Collaborator

Hey @sneko, how are you using Altair? The chrome extension? Which cookies do you expect to be sent with the request but aren't?

@sneko
Copy link
Author

sneko commented Dec 26, 2019

Yes I'm using the Chrome extension.

In the past months I was using Altair like that:

  • I have a protected API behind cookie verification
  • So I make sure my cookie is set and that I have access to the url (xxxx.com/graphql)
  • I go inside the Altair extension and use the above URL as graphql endpoint
  • I do some requests and Altair is able to reach my API since the cookie was set for the xxxx.com domain and it seems Altair was using the parameter credentials: 'include' so cookie are used even if cross-domain requests

But that was before. Now when looking in my Chrome console at my requests made from Altair, I no longer see the cookie in "request headers". I'm not sure from which side (Altair vs my side) the issue comes from so I preferred to ask you if some changes have been made.

Thank you,

@imolorhe
Copy link
Collaborator

imolorhe commented Dec 26, 2019

I don't think any of the changes I made to Altair recently would have changed that. I would suggest checking an older version of Altair https://github.com/imolorhe/altair/releases to compare the results with. I can verify if an updated version of the libraries has a different default, because I don't specify the credentials: "include" parameter myself.

GitHub
✨⚡️ A beautiful feature-rich GraphQL Client for all platforms. - imolorhe/altair

@sneko
Copy link
Author

sneko commented Dec 26, 2019

I'm looking for a way to make it working with last updates.

What would be the way you advise so I can inject an authentication cookie in all my request (or all requests for a specific chosen environment)?

I saw prerequest editor but I'm not able to use altair.helpers.getCookie('XXXXXX'); to get my cookie, the return string is always empty. Is there a way to specify from which domain I want to get the cookie?

Otherwise, a great solution in the Chrome Extension of GraphQL Playground is they allow customizing the HTTP parameter credentials I was talking about (include, omit, same-origin). It would be great if Altair could let the choice to the developer.

Note: if you made any change I don't understand why this is no longer working, subdependencies should not have modified defaults such as credentials. On the other hand, I'm able to provide cookies with GraphQL Playground (but I prefer Altair interface 😉 ). I definitely don't know what is the origin of this change 😆 ...

@imolorhe
Copy link
Collaborator

I can add the option to specify if the requests should be sent with credentials. Looking through the changes in git, I don't think credentials were ever included in the requests that were sent (the last change to that part of the code was about a year ago). Also looking at the git repo of the angular HttpClient module, the default for withCredentials is false meaning it doesn't send the cookies with the requests. You could set the cookie as headers in the desktop apps.

However, I think for some specific cases, the HttpClient module includes credentials but I haven't been able to verify that yet.

Ps: There's no way to specify the domain from which cookies for a request should be sent from. That would be a major security flaw in the web if that existed.

@imolorhe
Copy link
Collaborator

Another case when the cookies could have been sent is if you used Altair hosted on your own domain (or localhost), using one of the npm packages. In that case, the cookies are always sent since it is a same-site request.

@sneko
Copy link
Author

sneko commented Dec 27, 2019

That's really strange, I was just using the extension and the GraphQL API was for sure protected by cookie checking ^^... Anyway, I'm indeed interested by the option you mention, making us able to override the parameter if needed.

BTW, thank you for your work, Altair is an amazing GQL client 🎉

@imolorhe imolorhe added this to the v2.4.3 milestone Dec 28, 2019
@sneko
Copy link
Author

sneko commented Dec 28, 2019

Awesome reactivity @imolorhe ! Thanks! Can't wait for the release 🎉

@imolorhe
Copy link
Collaborator

imolorhe commented Jan 3, 2020

Hey @sneko, it seems the reason for the cookies change was due to changes to some of the permission of the browser extensions. I'll re-add those permissions again and the cookies should be sent again.

The permissions implicitly removed allowed the extension circumvent the CORS policy of the browsers for any domain. I hadn't realized that those permissions were responsible for this behavior. I'll re-add those permissions again in the next release.

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

No branches or pull requests

2 participants