bruno: [Bug] Cookies not sent
Version: 1.9.0
I have a collection with 2 requests inside, login and foo. When running login (POST, with data) I get a response with a set_cookie header :
< set-cookie: access_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJsb2dpbiI6InMuZmlub3RAY29tbS1pdC5pbyIsImlhdCI6MTcwOTA1MTcwM30.OeXYsgE5_U4ClUgvGi2vK0tJOiBBc96EMHBTcNnboqM; Path=/; HttpOnly; Secure
When running request foo (GET, not data), cookie is not sent despite it being listed in the cookies visible with the bottom-left cookie and get rejected because of missing access_token.
If I manually add the cookie header to the foo request, the request is properly authorized.
Also, cookie is properly updated each time I call login.
Both requests uses same protocol + url + port.
Both Store and Send Cookies automatically are enabled. I also tried to deactivate+save then activate+save as I was upgrading from 1.2.0.
I also tried using the runner, in case that could have an impact, but same result.
On a side note, I tried looking at the documentation on how to use the cookies, but could not find any reference.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 7
- Comments: 26 (4 by maintainers)
Honestly I have no idea as it doesnt break anything. I’ve also opened this same PR on tough-cookie which is the library they use under the hood and it’s been accepted into the v6 milestone which is coming out soon, I would be really surprised if it gets merged there before it’s merged here 😅
Hey, I opened a PR for this issue here that implements an RFC 6761 compliant URL trustworthiness check that allows
securecookies to be sent tolocalhostor another loopback address.@anusree-bruno Thank you, that works!
On the PR @sreelakshmi-bruno said they had to delay the PR because they were trying to get the OAuth stuff out. So hopefully it comes in the next release.
@BlockChainCaffe - The PR is still open and hasn’t been merged yet.
Ok looking quickly at the code, the issue I think is here:
https://github.com/usebruno/bruno/blob/main/packages/bruno-electron/src/utils/cookies.js#L14
specifically
Bruno uses tough-cookie. according to those docs you can send in an options opbject as a second argument.
By default it considers whether your connection is secure if you have https
So a suggest improvement might be to do something like this
Thoughts?
Could you try API with
http://? I found that Postman addsSecurecookies on header even onhttp://request, but bruno strictly handles it. If trying API withhttp://withSecurecookie, it does not send cookie onhttp://request.https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies