httpyac.github.io icon indicating copy to clipboard operation
httpyac.github.io copied to clipboard

GRPC cookie not saved

Open dragonnn opened this issue 2 years ago • 5 comments

Hi! Thanks for this amazing extension, helps a lot developing with GRPC! I am trying to setup my authentications Service with grpc, I see my cookie to be send back when I do the request

GRPC 127.0.0.1:8000/users.UserService/Login
{
  "login": "some_login",
  "password": "some_password"
}

HTTP/1.1 0 OK
content-type: application/grpc
set-cookie: auth=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJjM2JkMjhiOS1mZTQxLTRlM2YtOTA2Ny1mY2JmNjRkYTUzMzUiLCJzZXMiOjE0LCJleHAiOjE2NTU5MjEwNjUsImNydCI6MTY0NzI4MTA2NX0.IlqAQCRCIWF0Hh2j-VJL5mMGD5W4vmOLjZTh7MocJPo
date:
Mon, 14 Mar 2022 18:04:25 GMT
{
  "result": true,
  "info": "ok"
}

But when I try to send a next request from that file I my backend doesn't receive the cookie. My .http file looks like that:

proto < ./server/proto/users.proto
keepCase: true
longs: String
enums: String
defaults: false
oneofs: true

###

GRPC 127.0.0.1:8000/users.UserService/Login
{
  "login": "super_admin",
  "password": "1q2w3e"
}

GRPC 127.0.0.1:8000/users.UserService/KeepAlive
{}

Thanks for any help!

BTW. Using httpyac in vscode as an extension

dragonnn avatar Mar 14 '22 18:03 dragonnn

It would help me to have a small sample project with a server endpoint that simulates the behavior. The current client implementation is more or less my playground with GRPC and I have only very rudimentary experience. As soon as I find time I will be able to build the server component myself, but it will take some time.

AnWeber avatar Mar 16 '22 19:03 AnWeber

Sure, my project is currently also in a "toy" state, just need to pull out some not need bits and will publish something probably around this weekend :)

dragonnn avatar Mar 16 '22 19:03 dragonnn

https://github.com/dragonnn/tonic-cookie-test here is my quick test repo :) I am using rust as a backend but running it should be easy even if you never used rust, I prepared a devcontainer so you only need https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers do a open in container and click "> Run" on the bottom bar and the server will start. It has two rpc endpoints: SetCookie - sets a new cookie "name" with the content from the HelloRequest name field passed to it GetCookie - tries to find a cookie "name" and return it in HelloReply, if it doesn't find it it returns "name cookie not found"

dragonnn avatar Mar 20 '22 18:03 dragonnn

Hello, thank you for the test project. I was able to successfully start the server in it, but not yet call it, but there is very likely my current setup to blame. I'm on it.

AnWeber avatar Mar 22 '22 07:03 AnWeber

Just to update. I was able to start everything now and also extend the devcontainer with NodeJS. As a result, I have now already spent longer with the source code of @grpc/grpc-js. There in the file call-stream the set-cookie header is still received correctly, but it is not passed through to the outside. I am still trying to figure out from the existing documentation of @grpc/grpc-js. But it looks like this use case is currently not provided.

AnWeber avatar Mar 25 '22 21:03 AnWeber