update jwt-config generate section (#1036)

* update jwt-config generate section

* update jwt claim rule for auth0
This commit is contained in:
Praveen Durairaj 2018-11-15 18:51:25 +05:30 committed by Shahidh K Muhammed
parent b6773b36cd
commit 19a0dd9789
2 changed files with 28 additions and 0 deletions

View File

@ -315,3 +315,31 @@ And use it in the ``key`` field:
-----END CERTIFICATE-----
"
}
Add rules for custom JWT claims
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
In the Auth0 dashboard, navigate to "Rules". Add the following rules to add our custom JWT claims:
.. code-block:: javascript
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);
}
Generate JWT Config
^^^^^^^^^^^^^^^^^^^
The JWT Config to be used in env ``HASURA_GRAPHQL_JWT_SECRET`` or ``--jwt-secret`` flag can be generated using the following UI https://hasura.io/jwt-config.
Currently the UI supports generating config for Auth0 and Firebase. The config generated from this page can be directly pasted in yaml files and command line arguments as it takes care of escaping new lines.
.. image:: ../../../img/graphql/manual/auth/jwt-config-generated.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB