hasura / hasura/graphql-engine

Auth Webhook should support multiple roles X-HASURA-ROLES

Open
#7,005 5 comments 17 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
32.1k
Forks
3k
PR merge metrics
PR metrics pending

Description

It's normal that the user can have many roles. Eg: user = john can be contributor & admin

When using Auth Webhook, as of https://github.com/hasura/graphql-engine/issues/1420#issuecomment-455849733, developers should resolve multiple user roles to a particular role.

To do that, developers must somehow resolve GraphQL operation name (can't be trusted), variables, and query (pass as string from webhooks) to the GraphQL data -> the user's role -> return to Hasura. I think the point of Hasura is to reduce friction for developers to adopt GraphQL, and it defeats the point of using Hasura.

The straightforward way is for developers to return all user roles using X-HASURA-ROLES and lets Hasura handle the rest like JWT Auth.

[Auth Webhook's POST request](https://hasura.io/docs/latest/graphql/core/auth/authentication/webhook.html#post-request)
```
{
"headers": {
"header-key1": "header-value1",
"header-key2": "header-value2"
},
"request": {
"variables": {
"a": 1
},
"operationName": "UserQuery",
"query": "query UserQuery($a: Int) {\n users(where: {id: {_eq: $a}}){\n id\n }\n}\n"
}
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.