hasura / hasura/graphql-engine

Make x-hasura-allowed-roles field in JWT optional

Open
#8,402 0 comments 8 reactions 0 assignees View on GitHub
a/authz k/enhancement
Dominant language
TypeScript
Stars
32.1k
Forks
3k
PR merge metrics
PR metrics pending

Description

### Is your proposal related to a problem?

Right now `x-hasura-allowed-roles` is a required field in the JWT, this makes it so you can't just choose a JWT field as a role because you need a second field with that first field in array form.

Please see [this stackoverflow post for an example](https://stackoverflow.com/questions/71864595/how-to-map-correctly-to-make-x-hasura-allowed-roles-field-an-array-using-claim).

### Describe the solution you'd like

Make `x-hasura-allowed-roles` optional in the JWT, it can default to the value of `x-hasura-default-role`

### Describe alternatives you've considered

I'm not sure of an alternative if you don't have full control over the JWT

### If the feature is approved, would you be willing to submit a PR?

I don't know Haskell well enough unfortunately

Contributor guide

Open the contributing guide

Research direction

No file or test is named in the issue. Begin by tracing how JWT claims are validated and how x-hasura-default-role and x-hasura-allowed-roles are used; done means a JWT without the allowed-roles claim can use the default role without breaking existing role handling.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, haskell
Domain
api, authorization
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.