Hasura and auth0 setup

TODO: Migrations and metadata setup with hasura cli

Create an Auth0 Application

Configure Auth0 Rules & Callback URLs

In the settings of the application, add http://localhost:8888/callback as Allowed Callback URLs and Allowed Web Origins. Add domain specific URLs as well for production apps (e.g: https://mydomain.com/callback).

Open the Auth0 dashboard and then navigate to “Rules”. Then add a rule to add the custom JWT claims. You can name the rule anything you want.

**function** (user, context, callback) { **const** namespace = "<https://hasura.io/jwt/claims>"; context.idToken[namespace] = { 'x-hasura-default-role': 'user', *// do some custom logic to decide allowed roles*'x-hasura-allowed-roles': ['user'], 'x-hasura-user-id': user.user_id }; callback(**null**, user, context); }

Create an Auth0 API

You also need to create an API so that the access token issued by Auth0 is following the JWT standard. Read more about this here.

Configure Hasura to use Auth0 Keys

Visit this url, select Auth0 as the provider and enter your domain.