Allow auth webhook to set cookies on response
See original GitHub issueHasura does not currently (unless I’m doing something wrong) forward the Set-Cookie header from auth webhooks. This issue is similar to but different from #1654
Use cases:
- Setting a tracking cookie on unauthenticated requests
- Resetting cookie maxAge on each request. This would be very useful for cookies that expire within a set, short amount of time.
One option would be to forward the Set-Cookie header set by auth webhook to the response.
Another, more explicit option would be for the webhook to explicitly respond with a cookies
object, and for those to be set on the response.
Here are two possible syntaxes for the auth webhook response:
{
"X-Hasura-User-Id": "25",
"X-Hasura-Role": "user",
"X-Hasura-Is-Owner": "true",
"X-Hasura-Custom": "custom value",
"Cookies": {
"<cookie-name>": {
"Value": "<cookie-value>",
"Expires": "<date>"
"Max-Age": <non-zero-digit>,
"Domain": "<domain-value>",
"Path": "<path-value>",
"Secure": <boolean>,
"HttpOnly": <boolean>,
"SameSite": "<Strict/Lax>"
}
},
"Cookies": [
{
"Name": "<cookie-name>",
"Value": "<cookie-value>",
"Expires": "<date>"
"Max-Age": <non-zero-digit>,
"Domain": "<domain-value>",
"Path": "<path-value>",
"Secure": <boolean>,
"HttpOnly": <boolean>,
"SameSite": "<Strict/Lax>"
}
]
}
Another, even more general purpose way would be to allow a special headers
property. This would allow the webhook to set any header. Example syntaxes:
{
"X-Hasura-User-Id": "25",
"X-Hasura-Role": "user",
"X-Hasura-Is-Owner": "true",
"X-Hasura-Custom": "custom value",
"Response-Headers": [
{
"name": "Set-Cookie",
"value": "<cookie-name>=<cookie-value>; Expires: <date>; Max-Age: <non-zero-digit>; Domain: <domain-value>; Path: <path-value>; Secure: <boolean>; HttpOnly: <boolean>; SameSite: <Strict/Lax>",
}
],
"Response-Headers": [
"Set-Cookie: <cookie-name>=<cookie-value>; Expires: <date>; Max-Age: <non-zero-digit>; Domain: <domain-value>; Path: <path-value>; Secure: <boolean>; HttpOnly: <boolean>; SameSite: <Strict/Lax>",
]
}
Issue Analytics
- State:
- Created 4 years ago
- Reactions:15
- Comments:12 (4 by maintainers)
Top Results From Across the Web
WebHook Cookie Header Response Post Session ...
I'm trying to use an API to fetch data automatically using WEBHOOKS. It looks like the POST authentication mode is session auth. The...
Read more >Authentication using webhooks | Hasura GraphQL Docs
If the Set-Cookie HTTP headers are set by the auth webhook, they are forwarded by the GraphQL Engine as response headers for both...
Read more >Secure Your Webhooks - Contentstack
To set this method, go to Settings > Webhooks. Here, you can add the basic auth details by providing the values for the...
Read more >Cookie-based auth for REST APIs - Atlassian Developer
Before you begin · Overview · Step 1. Create a new session using the Jira REST API · Step 2. Use the session...
Read more >Webhook service | Dialogflow ES - Google Cloud
Enable and manage fulfillment · Select Intents in the left sidebar menu. · Select an intent. · Scroll down to the Fulfillment section....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This issue is critical to being able to fully use auth webhook securely (storing token in cookie instead of localStorage). Will this be addressed ever?
Would it be possible to have any visibility into this feature? Hasura is great. Not having access to cookies as an authentication mechanism is frustrating. I see that you may not want to pile too much into the auth webhook, but you are going to get a lot of feature requests there since it’s the main mechanism to auth/filter/control/manipulate/monitor all the requests.