Cannot combine a JWT token with other X-Hasura-* headers
In our application a single user account can have access to multiple brands with different levels of access. Almost every table includes a brand_id so that the data is all filtered to the correct brand. The intention was to set up the permissions system such that an X-Hasura-Brand-Id header can be set indicating which brand is being access and then all row filtering and other operations will be restricted to that brand and the permissions can be checked for the combination of that brand and user.
However I'm using Auth0 for authentication and passing JWT tokens and have run across this limitation. I don't think I can put x-hasura-brand-id into the JWT as it's something I want the customer to be able to change dynamically without logging in again and having to generate and swap between different tokens for each brand will get quite messy.
The ideal situation for me would be if Hasura let me override permissions headers (with the exception of x-hasura-allowed-roles) on the request.
Related to https://github.com/hasura/graphql-engine/issues/1601
@ledburyb did you find a suitable solution or workaround to this? We're having exactly the same requirement 😄
@bastianwegge - I just wrote my own JWT validation backend in the end and set it to forward any headers I set in a whitelist (This is important for security or someone could overwrite X-Hasura-User-Id itself).
@ledburyb thanks for coming back so quickly!
That's exactly what we think of doing using a Gateway in front of Hasura. Did you end up using the webhook method then? Or did you deactivate authentication in Hasura completely to go with the HASURA_GRAPHQL_UNAUTHORIZED_ROLE approach?
e: Or did you even go down the "create your own JWT" road?
I used HASURA_GRAPHQL_AUTH_HOOK_MODE, still with Auth0 tokens from JWT.
Hi @ledburyb I work on the community team at Hasura and I'd like to learn a little more about this. Is there some way I could DM you?
Thanks,
@a-chocolate-bear Not OP but this is an issue that we're experiencing/interested in. Happy to chat, my email is in my profile.