Skip to content
This repository has been archived by the owner on May 26, 2022. It is now read-only.

Latest commit

 

History

History
46 lines (40 loc) · 3.73 KB

auth0-howto.md

File metadata and controls

46 lines (40 loc) · 3.73 KB

To-Do: Automate getting JWT_SECRET and AUTH_DIRECTIVES_ROLE_KEY

It is possible to automate the below steps. However, Below are manual steps listed.

Auth0 for Grand Stack in

  1. Navigate to https://manage.auth0.com/dashboard/. If you do not have an auth0 account, create one under the free plan.
  2. Create a new application on Auth0 (Singple Page Applications - SPA). If you have already created an application on Auth0 for GRANDstack, Skip this step.
  3. For AUTH_DIRECTIVES_ROLE_KEY, Under the application settings, Copy value of Domain under basic information. the domain information https://<DOMAIN>/roles
  4. Visit settings under this application, Scroll to the bottom and select Show Advanced Settings.
  5. Advanced Settings has various tabs. Under the tab named Certificates, copy the text in the box for Signing Certificate. This is our JWT_SECRET.
  6. Ensure that you add CRLF to the JWT_SECRET as we need this to be a string. Please Check the Instance below for reference only.

Explaining AUTH_DIRECTIVES_ROLE_KEY

  1. Auth0 - Roles, Permissions and Scopes are sent to a user's accessToken (JWT).
  2. If you are using auth0-spajs or auth-reactjs, JWT can be received with getTokenSilently. Snippet: const accessToken = await auth0Client.getTokenSilently();
  3. Decode the token on jwt.io. You will notice that a key that looks AUTH_DIRECTIVES_ROLE_KEY contains roles, permissions and scopes as a array.
  4. In-Short, AUTH_DIRECTIVES_ROLE_KEY helps us to automatically tell graphql to use this key for roles.

Instance - JWT_SECRET

Instance: Signing certificate may look like this.

-----BEGIN CERTIFICATE-----
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx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