Hasura + Firebase: using the new "claims_map" feature in Hasura 1.3.3 to set default role

Viewed 209

I am using this method to auth a Flutter app with Firebase. The gist is when a new account is created, a cloud function is run to apply the claims to the new Firebase user account so Hasura can use them. The issue is this happens 1-10 (maybe more) seconds after the account has been created, so I cannot log them in for some arbitrary amount of time until the claims are applied.

I want to use the new claims_map functionality in Hasura 1.3.3 to apply default claims to a logged in user, to be overridden if a user has claims already in Firebase.

Since this feature is very new, does anyone have experience in setting this up?

1 Answers

You may have already answered this yourself. In case not, then if you have already set up everything according to those instructions, the only thing you need to do is add a line to HASURA_GRAPHQL_JWT_SECRET, maybe something like this:

 "claims_map": {"x-hasura-allowed-roles":["user"],"x-hasura-default-role":"user","x-hasura-user-id":{"path":"$.user_id"}}

It just works.

Related