0

I am trying to set claims_map in HASURA_GRAPHQL_JWT_SECRET in my docker compose file using the below config

HASURA_GRAPHQL_JWT_SECRET: '{"type":"HS256","key":"***************************","claims_namespace":"p-clamis-allow","claims_map":{"x-hasura-user-id":{"path":"$.user.id"}}}'

I get the following error:

Invalid interpolation format for "environment" option in service "graphql-engine":"{"type":"HS256","key":"*************************","claims_namespace":"p-clamis-allow","claims_map":{"x-hasura-user-id":{"path":"$.user.id"}}}"**

Rolwin Crasta
  • 4,219
  • 3
  • 35
  • 45

2 Answers2

3

Replace $ with $$ and things should work!

HASURA_GRAPHQL_JWT_SECRET: '{"type":"HS256","key":"***************************","claims_namespace":"p-clamis-allow","claims_map":{"x-hasura-user-id":{"path":"$$.user.id"}}}'

iamnat
  • 4,056
  • 1
  • 23
  • 36
  • Thanks for the inputs, infact i tried this and used the below JSON payload for the JWT but it does not accept the user.id. I get the error "\"x-hasura-user-id\" header is expected but not found" Payload: { "name": "Test", "user": { "id": "123" }, "p-clamis-allow": { "x-hasura-allowed-roles": [ "user","admin" ], "x-hasura-default-role": "user" } } – Rolwin Crasta Jun 25 '21 at 07:09
  • Is there a typo in your `p-claims-allow` attribute there? – Bharat Kashyap Jun 26 '21 at 08:40
  • No, i was using Hasura 1.XX, i upgraded to hasura/graphql-engine:v2.0.1 and it started working – Rolwin Crasta Jul 01 '21 at 03:48
1

This will work with

export HASURA_GRAPHQL_JWT_SECRET="{ \"type\": \"HS256\", \"key\": \"***************************\",\"claims_namespace\":\"p-claims-allow\"}" 
Balusamy M
  • 11
  • 2
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jun 21 '23 at 11:38