hasura / hasura/graphql-engine

X-Hasura-Allowed-Roles without X-Hasura-Role

Open
#9,837 1 comment 1 reaction 0 assignees View on GitHub
k/enhancement
Dominant language
TypeScript
Stars
32.1k
Forks
3k
PR merge metrics
PR metrics pending

Description

### Is your proposal related to a problem?

Currently I use jwt and dynamically give the user groups.
Examples (X-Hasura Allowed Roles):
```
"user",
"network",
"interne-it",
"department2",
```
I always set the default role to "user" (X-Hasura-Default-Role).

Now comes the huge problem I have with Hasura.
The user has to choose his role himself via X-Hasura-Role.

He can accept all of them, why do I have to specify it at all?

Since I don't know with the other application which group is now required for the authorization, I would have to send 4 queries and see which role data comes back with.

```
X-Hasura-Role: "user" => no data
X-Hasura role "network" => no data
X-Hasura-Role: "interne-it" => no data
X-Hasura-Role: "abteilung2" => has permissions and gets data
```

### Describe the solution you'd like
1. Possibility to sort the roles in Hasura.
2. the possibility to specify several roles in X-Hasura-Role or X-Hasura-Roles
3. the possibility of X-Hasura-Roles: X-Hasura-Allowed-Roles (i.e. specifying all without having to hand them over manually)

Subsequently, hasura gradually checks which role has set permissions.
In addition, row select permission is also validated.
The first one that has permissions to read rows after sorting from 1. is used.

### Describe alternatives you've considered

At the moment I can't imagine any alternative, because roles don't actually work according to selection but rather according to groups.
Hasura is the first application I've ever seen where you have to explicitly specify the role.
This restrictiveness is very cumbersome for multi-role permissions.

Alternative:?
https://github.com/hasura/graphql-engine/issues/7365

https://github.com/hasura/graphql-engine/issues/9485 + Array Support https://github.com/hasura/graphql-engine/issues/1902

Contributor guide

Open the contributing guide

Research direction

Start by reading the linked discussions in issues 7365, 9485, and 1902, then trace how Hasura currently interprets X-Hasura-Role and X-Hasura-Allowed-Roles. The work is done when the intended role ordering or multi-role selection behavior, including row permissions, is agreed and implemented with corresponding validation.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql
Domain
api, authorization
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.