why is x-hasura-default-role is prefered over x-hasura-role
See original GitHub issueHi! Thank you for your awesome work.
I have an issue with jwt. While using this HASURA CLAIMS:
{ "x-hasura-default-role": "anonymous", "x-hasura-allowed-roles": [ "user", "anonymous", "admin", "institution-admin" ], "x-hasura-role": "user", "x-hasura-user-id": "rglCjqnVAKbBx0Q7jke73blCKmu1" }
Hasura identifies request sender as anonymous
When changed to this HASURA CLAIMS:
{ "x-hasura-default-role": "user", "x-hasura-allowed-roles": [ "user", "anonymous", "admin", "institution-admin" ], "x-hasura-role": "user", "x-hasura-user-id": "rglCjqnVAKbBx0Q7jke73blCKmu1" }
Hasura identifies request sender as user
Why can this be happening?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:5
- Comments:10 (1 by maintainers)
Top Results From Across the Web
Using JWTs for GraphQL Authorization with Hasura - Morioh
[“The Hasura platform takes advantage of JWT and GraphQL technologies to ... roles as well as the default role in the absence of...
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
x-hasura-role
has to be sent with the http request. It is not expected to be part of the JWT’s hasura claims and as such it is ignored. Thex-hasura-role
sent with the request is checked to see if it is part of thex-hasura-allowed-roles
and if yes, the request is executed as that role. In case thex-hasura-role
is missing, thex-hasura-default-role
from the JWT is used.@dohomi Initially I also thought it is a security issue. But then realized that auth server should return correct role list (
x-hasura-allowed-roles
). Which means that the roles in the list are the only roles that can be put intox-hasura-role
header.