postgresqlroleshasurahasura-jwt

Where are Hasura roles stored?


I want to create authentication apis in Hasura. My user can have differrent roles when signing up. Thinking of maintaining an Enum table for the same. So that I can have a foreign key/type from it in the user table. However, I intend to create a postgress trigger on this enum table, such that everytime, new role is added, a new hasura role should also be created to allow for JWT authentication and authorization accordingly. Where does hasura stores its Hasrua role.


Solution

  • Answer 1 (direct answer)

    Not sure this is something the app developer should edit.

    All Hasura metadata (including roles/permissions) is in Postgres.

    The schema is "hdb_catalog". The table is "hdb_metadata".

    You can query this using:

    SELECT * FROM "hdb_catalog"."hdb_metadata" WHERE id = 1;
    

    It contains a large JSON document. It's better to look at it using PGAdmin.

    Answer 2 (dynamic roles)

    It looks like you're trying to get dynamic roles in place. There is a great Youtube video that explains how to model it:

    https://youtu.be/-18zZO3DrLY?t=1370