mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-15 17:31:56 +03:00
update jwt-config generate section (#1036)
* update jwt-config generate section * update jwt claim rule for auth0
This commit is contained in:
parent
b6773b36cd
commit
19a0dd9789
@ -315,3 +315,31 @@ And use it in the ``key`` field:
|
|||||||
-----END CERTIFICATE-----
|
-----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
|
||||||
|
BIN
docs/img/graphql/manual/auth/jwt-config-generated.png
Normal file
BIN
docs/img/graphql/manual/auth/jwt-config-generated.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 52 KiB |
Loading…
Reference in New Issue
Block a user