🔐Deploying with Auth0

For this deployment method, using your Auth0 credentials in the Astral Auth0 Plugin, will streamline User Management, Team Management, and API Credentials.

To use Auth0 for your Astral Dx Portal API Credential Management you will need to set up two Auth0 “Machine-to-Machine” clients, one for your production environment and one for your sandbox environment. To get started create or select the Auth0 Tenants you will use for production and sandbox.

Please visit the Astral API Portal Launcher to configure and download your API Portal.

If you are using Auth0 for API credentials, you can deploy an API Developer Portal quickly with two steps:

  1. Setup Auth0 Clients

  2. Test your API Portal Locally and Deploy

View an end-to-end training video for deploying in under 10 minutes

Step 1: Setup Auth0 Clients

  1. Within Auth0, select your production tenant using the tenant dropdown

2. Navigate to “Applications” using the left side navigation and select “Applications” \

3. Select “Create Application”

4. Set the name of the new application to “Astral Backend” and choose “Machine to Machine Applications” as the application type

5. Select “Auth0 Management API” and enable read, write, update, and delete for the following permissions:

  • client_grants

  • users

  • users_app_metadata

  • clients

  • client_keys

6. Open the “Settings” tab on the application you have just created and provide the values as the following environment variables to your Astral Dx Portal

  • Domain: PRODUCTION_AUTH0_MANAGEMENT_CLIENT_DOMAIN

  • Client ID: PRODUCTION_AUTH0_MANAGEMENT_CLIENT_ID

  • Client Secret: PRODUCTION_AUTH0_MANAGEMENT_CLIENT_SECRET

7. Follow Steps 1 through 5 within the context of your Auth0 Sandbox tenant to create a second set of Astral Backend credentials (for your sandbox environment) and provide the values as the following environment variables

  • Domain: SANDBOX_AUTH0_MANAGEMENT_CLIENT_DOMAIN

  • Client ID: SANDBOX_AUTH0_MANAGEMENT_CLIENT_ID

  • Client Secret: SANDBOX_AUTH0_MANAGEMENT_CLIENT_SECRET

8. Set Permissions for your first admin user

One time step. For the very first user to log into your portal you'll need to manually add the portal-admin permission within Auth0:

  • Navigate to "User Management", then "Users"

  • Find or create your user

  • Copy or amend the app_metadata to include the following property

{
  "permissions": ["portal-admin"]
}

Step 2: Test your API Portal Locally and Deploy

  1. Open a local development environment with tools including Git for source version control, and Node.js and npm to install and run the Auth0 Deploy CLI locally.

  2. With the template repository, create an .env.local at the root of the project and provide any necessary environment variables.

# .env.local

# For Auth0 Authencation
AUTH0_SECRET=
AUTH0_BASE_URL=http://localhost:3000
AUTH0_ISSUER_BASE_URL=
AUTH0_CLIENT_ID=
AUTH0_CLIENT_SECRET=

# For Auth0 Team Management
AUTH0_ADMIN_INVITE_SIGNING_SECRET=
AUTH0_TEAM_INVITE_SIGNING_SECRET=

# For Auth0 API Credentials
PRODUCTION_AUTH0_MANAGEMENT_CLIENT_DOMAIN=
PRODUCTION_AUTH0_MANAGEMENT_CLIENT_ID=
PRODUCTION_AUTH0_MANAGEMENT_CLIENT_SECRET=
SANDBOX_AUTH0_MANAGEMENT_CLIENT_DOMAIN=
SANDBOX_AUTH0_MANAGEMENT_CLIENT_ID=
SANDBOX_AUTH0_MANAGEMENT_CLIENT_SECRET=

3. Next, run the development server:

npm run dev
# or
yarn dev

4. Open http://localhost:3000 with your browser to see the result.

You can start customizing your API developer portal by modifying portal.config.js. Refresh your page to see changes.

Example portal.config.jsto UI visuals:

New to Auth0 for User and Team Management? Checkout this free setup from Auth0:

Last updated