How to Customize Action code in Different Tenants with Auth0 Deploy CLI

Overview

This article explains how to use Action secrets in Auth0 Deploy CLI to replace variables in an Auth0 Action code that needs to be set differently in different tenants.

For example:

Dev tenant:

exports.onExecutePostLogin = async (event, api) {
  const URL = 'https://url-dev.com';
  // Use the URL variable to do some business logic in the DEV tenant
}

UAT tenant:

exports.onExecutePostLogin = async (event, api) {
  const URL = 'https://url-uat.com';
  // Use a different URL with the URL variable to do the same business logic in the UAT tenant
}

Applies To

  • Auth0 Deploy CLI
  • Customize Action Code

Solution

One solution to this use case is to use the Action secrets to manage the changing attributes in the Action’s code.

For example:

exports.onExecutePostLogin = async (event, api) {
  const URL = event.secrets.URL;
  // Use the URL variable populated from the Secrets.
  // This solution ensures the Action code is the same across different tenants.
}

This will allow updating the secrets following the guidance in the knowledge article Keyword Preservation not Working with Action Secrets.