### Install Dependencies and Start Development Server
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/docs/how-to-contribute.md
Run these commands after cloning the repository to install project dependencies and start the development server which continuously watches for source file changes.
```shell
npm install
npm run dev
```
--------------------------------
### Clone Repository and Setup
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/CONTRIBUTING.md
Clone your forked repository and set up the upstream remote. Install project dependencies.
```bash
git clone https://github.com/YOUR_USERNAME/auth0-deploy-cli.git
cd auth0-deploy-cli
git remote add upstream https://github.com/auth0/auth0-deploy-cli.git
```
```bash
# Install dependencies
npm i
```
--------------------------------
### Directory Structure Example
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/docs/resource-specific-documentation.md
Example of the file structure for client configurations.
```text
./clients/
./My API Client.json
```
--------------------------------
### Install Dependencies and Build Project
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/AGENTS.md
Commands to install project dependencies, build the TypeScript project to JavaScript, and build in watch mode for development.
```bash
# Install dependencies
npm install
# Build TypeScript to JavaScript
npm run build
# Build in watch mode during development
npm run dev
```
--------------------------------
### Client Configuration JSON
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/docs/resource-specific-documentation.md
Example of a client configuration file including the 'pem' field for deployment.
```json
{
"name": "My API Client",
"client_authentication_methods": {
"private_key_jwt": {
"credentials": [
{
"name": "my-key-v2",
"credential_type": "public_key",
"pem": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkq...\n-----END PUBLIC KEY-----\n"
}
]
}
}
}
```
--------------------------------
### Install Auth0 Deploy CLI
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/README.md
Install the Auth0 Deploy CLI globally to use it as a standalone command-line tool. Ensure Node.js version 20 or greater is installed.
```shell
npm install -g auth0-deploy-cli
```
--------------------------------
### Configure Prompts in YAML Mode
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/docs/resource-specific-documentation.md
Example of the folder structure and tenant.yaml configuration for managing prompts when using YAML mode.
```text
Folder structure when in YAML mode.
./prompts/
/screenRenderSettings
/signup-id_signup-id.json
/login-id_login-id.json
/login-passwordless_login-passwordless-email-code.json
/login-passwordless_login-passwordless-sms-otp.json
./tenant.yaml
```
```yaml
# Contents of ./tenant.yaml
prompts:
identifier_first: false
universal_login_experience: new
webauthn_platform_first_factor: false
customText:
en:
login:
login:
description: Login description in english
buttonText: Button text
passkeys:
passkey-enrollment:
title: Create a passkey for ${clientName}
createButtonText: Create a passkey
partials:
login:
login:
form-content-start: |
Welcome! Please log in to continue.
passkeys:
passkeys-enrollment:
form-content-start: |
passkeys-enrollment-local:
form-footer-end: |
This passkey will be saved to this device only.
screenRenderers:
- signup-id:
signup-id: ./prompts/screenRenderSettings/signup-id_signup-id.json
- login-passwordless:
login-passwordless-email-code: ./prompts/screenRenderSettings/login-passwordless_login-passwordless-email-code.json
login-passwordless-sms-otp: ./prompts/screenRenderSettings/login-passwordless_login-passwordless-sms-otp.json
```
--------------------------------
### Configure Prompts in Directory Mode
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/docs/resource-specific-documentation.md
Example of the folder structure and manifest files required for managing prompts in directory mode.
```text
Folder structure when in directory mode.
./prompts/
./partials/
./login/
./login/
./form-content-start.liquid
./passkeys/
./passkeys-enrollment/
./form-content-start.liquid
./passkeys-enrollment-local/
./form-footer-end.liquid
./screenRenderSettings/
./signup-id_signup-id.json
./login-id_login-id.json
./login-passwordless_login-passwordless-email-code.json
./login-passwordless_login-passwordless-sms-otp.json
./login-password_login-password.json
./signup-password_signup-password.json
./custom-text.json
./partials.json
./prompts.json
```
```json
{
"en": {
"login": {
"login": {
"description": "Login description in english",
"buttonText": "Button text"
}
},
"passkeys": {
"passkey-enrollment": {
"title": "Create a passkey for ${clientName}",
"createButtonText": "Create a passkey"
}
}
}
}
```
```json
{
"login": [
{
"login": [
{
"name": "form-content-start",
"template": "partials/login/login/form-content-start.liquid"
}
]
}
],
"passkeys": [
{
"passkeys-enrollment": [
{
"name": "form-content-start",
"template": "partials/passkeys/passkeys-enrollment/form-content-start.liquid"
}
],
"passkeys-enrollment-local": [
{
"name": "form-footer-end",
"template": "partials/passkeys/passkeys-enrollment-local/form-footer-end.liquid"
}
]
}
]
}
```
--------------------------------
### Example File Structure for Multi-environment Configs
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/docs/multi-environment-workflow.md
Organize your project to include separate configuration files for each environment within an 'auth0' directory. This structure supports environment-specific settings while keeping resource configurations centralized.
```tree
project-root
│
└───auth0
│ │ config-dev.json # Dev env config file
│ │ config-test.json # Test env config file
│ │ config-prod.json # Prod env config file
│ │ ... all other resource configuration files
│
└───src
│ ... your project code
```
--------------------------------
### Auth0 Deploy CLI Configuration Example
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/examples/directory/README.md
Example JSON configuration file for the Auth0 Deploy CLI. This file specifies authentication details, keyword replacements, and properties to include or exclude during export/import operations. By default, the tool merges environment variables, overriding config.json values with the same top-level key, which can be disabled with the `--no-env` option.
```json
{
"AUTH0_DOMAIN": "",
"AUTH0_CLIENT_SECRET": "",
"AUTH0_CLIENT_ID": "",
"AUTH0_KEYWORD_REPLACE_MAPPINGS": {
"YOUR_ARRAY_KEY": [
"http://localhost:8080",
"https://somedomain.com"
],
"YOUR_STRING_KEY": "some environment specific string"
},
"AUTH0_ALLOW_DELETE": false,
"INCLUDED_PROPS": {
"clients": [ "client_secret" ]
},
"EXCLUDED_PROPS": {
"connections": [ "options.client_secret" ]
},
"AUTH0_EXCLUDED_RULES": [ "auth0-account-link-extension" ],
"AUTH0_EXCLUDED_CLIENTS": [ "auth0-account-link" ],
"AUTH0_EXCLUDED_RESOURCE_SERVERS": [ "SSO Dashboard API" ],
"AUTH0_EXCLUDED_DEFAULTS": ["emailProvider"]
}
```
--------------------------------
### Production Environment Configuration
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/docs/multi-environment-workflow.md
Example JSON configuration file for the production environment. Customize domain, client ID, and other settings as needed.
```json
{
"AUTH0_DOMAIN": "travel0.us.auth0.com",
"AUTH0_CLIENT_ID": "vZCEFsDYzXc1x9IomB8dF185e4cdVah5",
"AUTH0_ALLOW_DELETE": false,
"AUTH0_KEYWORD_REPLACE_MAPPINGS": {
"ENV": "prod",
"ALLOWED_ORIGINS": ["http://travel0.com"]
}
}
```
--------------------------------
### `deploy` function
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/docs/using-as-node-module.md
Applies configurations from the local machine to the Auth0 tenant. Note that Marketplace Actions cannot be installed by the Deploy CLI.
```APIDOC
## `deploy` function
Applies configurations from local machine to Auth0 tenant.
> **Note**
> Marketplace Actions cannot be installed by the Deploy CLI. If your configuration references marketplace Actions, install them manually in the target tenant before running `deploy`.
### Parameters
#### `input_file`
Path. Specifies the location of the resource configuration files. For YAML formats, this will point to the tenant.yaml file. For directory formats, this will point to the resource configuration directory.
#### `config`
Object. Configures behavior of utility. Refer to the list of [all configurable properties](./configuring-the-deploy-cli.md).
#### `config_file`
Path. Specifies the user-defined configuration file (config.json). Refer to the list of [all configurable properties](./configuring-the-deploy-cli.md).
#### `export_ids`
Boolean: When enabled, will export the identifier fields for each resource. Default: `false`.
#### `env`
Boolean. Indicates if the tool should ingest environment variables or not. Default: `false`.
#### `proxy_url`
A url for proxying requests. Only set this if you are behind a proxy.
### Example
```ts
import { deploy } from 'auth0-deploy-cli';
deploy({
input_file: './local/tenant.yaml',
config: {
AUTH0_DOMAIN: '',
AUTH0_CLIENT_ID: '',
AUTH0_CLIENT_SECRET: '',
},
})
.then(() => {
console.log('Auth0 configuration applied to tenant successful');
})
.catch((err) => {
console.log('Error when applying configuration to Auth0 tenant:', err);
});
```
```
--------------------------------
### Mocking Auth0 Client and Configuration for Tests
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/AGENTS.md
Example JavaScript code demonstrating how to mock the Auth0 client and configuration settings for testing resource handlers. Uses sinon for stubbing.
```javascript
const mockClient = {
resource: {
getAll: sinon.stub(),
create: sinon.stub(),
update: sinon.stub(),
delete: sinon.stub(),
},
};
const mockConfig = (key) => {
const config = {
AUTH0_ALLOW_DELETE: true,
AUTH0_EXCLUDED: [],
};
return config[key];
};
```
--------------------------------
### Implement Action Module Logic
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/docs/resource-specific-documentation.md
Example implementation of an action module using Node.js dependencies.
```javascript
const jwt = require('jsonwebtoken');
const axios = require('axios');
/**
* Auth Helper Module
* Provides JWT validation and token refresh utilities
*/
module.exports = {
async validateToken(token) {
const secret = actions.secrets.JWT_SECRET;
try {
return jwt.verify(token, secret);
} catch (error) {
throw new Error('Invalid token: ' + error.message);
}
},
async fetchUserData(userId) {
const response = await axios.get(`https://api.example.com/users/${userId}`);
return response.data;
},
};
```
--------------------------------
### Example of Empty Resource Configurations
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/docs/excluding-from-management.md
Define resource configurations as empty to signal intentional emptying or deletion. This example shows empty connections, an effectively no-op tenant configuration, and an email provider configuration that will trigger deletion.
```yaml
connections: [] # Empty connections
tenant: {} # Effectively a no-op, cannot delete tenant
emailProvider: {} # Will delete email provider
```
--------------------------------
### Configure CLI via environment variables
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/docs/configuring-the-deploy-cli.md
Examples of setting environment variables for authentication and disabling variable ingestion, as well as passing complex JSON structures.
```shell
# Deploying configuration for YAML formats without a config.json file
export AUTH0_DOMAIN=
export AUTH0_CLIENT_ID=
export AUTH0_CLIENT_SECRET=
a0deploy import --input_file=local/tenant.yaml
# Disable environment variable ingestion
a0deploy export -c=config.json --format=yaml --output_folder=local --env=false
# Non-primitive configuration values
export AUTH0_EXCLUDED='["actions","organizations"]'
export AUTH0_KEYWORD_REPLACE_MAPPINGS='{"ENVIRONMENT":"dev"}'
a0deploy export -c=config.json --format=yaml --output_folder=local
```
--------------------------------
### Deploy Local Configuration to Auth0 Tenant
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/docs/using-as-node-module.md
Use the `deploy` function to apply configurations from your local machine to an Auth0 tenant. Specify the input file path, and provide authentication credentials. Ensure Marketplace Actions are manually installed if referenced.
```typescript
import { deploy } from 'auth0-deploy-cli';
deploy({
input_file: './local/tenant.yaml',
config: {
AUTH0_DOMAIN: '',
AUTH0_CLIENT_ID: '',
AUTH0_CLIENT_SECRET: '',
},
})
.then(() => {
console.log('Auth0 configuration applied to tenant successful');
})
.catch((err) => {
console.log('Error when applying configuration to Auth0 tenant:', err);
});
```
--------------------------------
### Example of Omitting Roles Configuration
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/docs/excluding-from-management.md
Omit configurations by not including them in the deployment file. This example shows roles being configured, implying other configurations not present will be skipped.
```yaml
roles: # roles configuration is not omitted
- name: Admin
description: Can read and write things
permissions: []
- name: Reader
description: Can only read things
permissions: []
# The omission of all other configurations means they'll be skipped over
```
--------------------------------
### Auth0 Deploy CLI Configuration JSON
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/examples/yaml/README.md
Example `config.json` file for Auth0 Deploy CLI. It includes settings for domain, client credentials, deletion policies, keyword replacement mappings, and property inclusions/exclusions.
```json
{
"AUTH0_DOMAIN": "",
"AUTH0_CLIENT_SECRET": "",
"AUTH0_CLIENT_ID": "",
"AUTH0_ALLOW_DELETE": false,
"AUTH0_KEYWORD_REPLACE_MAPPINGS": {
"YOUR_ARRAY_KEY": [
"http://localhost:8080",
"https://somedomain.com"
],
"YOUR_STRING_KEY": "some environment specific string"
},
"INCLUDED_PROPS": {
"clients": [ "client_secret" ]
},
"EXCLUDED_PROPS": {
"connections": [ "options.client_secret" ]
},
"AUTH0_EXCLUDED_RULES": [ "auth0-account-link-extension" ],
"AUTH0_EXCLUDED_CLIENTS": [ "auth0-account-link" ],
"AUTH0_EXCLUDED_RESOURCE_SERVERS": [ "SSO Dashboard API" ],
"AUTH0_EXCLUDED_DEFAULTS": ["emailProvider"]
}
```
--------------------------------
### Use Keyword Replacement in tenant.yaml
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/docs/keyword-replacement.md
Inject keywords into your YAML configuration files using `##KEYWORD##` for literal replacement or `@@KEYWORD@@` for stringified replacement. This example shows how to use `##ENVIRONMENT##` and `@@ALLOWED_LOGOUT_URLS@@`.
```yaml
tenant:
friendly_name: '##ENVIRONMENT## tenant'
allowed_logout_urls: '@@ALLOWED_LOGOUT_URLS@@'
enabled_locales:
- en
clients:
- name: Test App
allowed_origins: '@@ALLOWED_ORIGINS@@'
allowed_logout_urls: '@@ALLOWED_LOGOUT_URLS@@'
```
--------------------------------
### Define Individual Phone Template in JSON
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/docs/resource-specific-documentation.md
Example of a single phone template configuration file for the phone-templates directory.
```json
{
"type": "otp_verify",
"disabled": false,
"content": {
"from": "+12341234567",
"body": {
"text": "Your verification code is {{ code }}",
"voice": "Your verification code is {{ code }}"
}
}
}
```
--------------------------------
### Import Tenant Configuration from Directory
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/AGENTS.md
Command to import Auth0 tenant configuration from a local directory. Ensure the project is built first.
```bash
npm run build && node lib/index.js import -c config-dev.json -i ./local/tenant.json
```
--------------------------------
### Import Tenant Configuration from Directory
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/examples/directory/README.md
This command imports your Auth0 tenant configuration from a directory structure. Ensure you have copied and filled out the `config.json.example` file with your specific details before running the import.
```bash
a0deploy import -c config.json -i .
```
--------------------------------
### Beta Versioning
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/CONTRIBUTING.md
Create a pre-release version (beta) for the project using npm.
```bash
npm version prerelease --preid beta --no-git-tag-version
```
--------------------------------
### Import Tenant Configuration from YAML
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/AGENTS.md
Command to import Auth0 tenant configuration from a local YAML file. Ensure the project is built first.
```bash
npm run build && node lib/index.js import -c config-dev.json -i ./local-export/tenant.yaml
```
--------------------------------
### Run Build, Test, and Lint Before Committing
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/AGENTS.md
Execute these commands before committing to ensure code quality and test coverage.
```bash
npm run build
npm test
npm run lint
```
--------------------------------
### Dry Run Validation Error Example
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/docs/using-dry-run.md
Dry run performs the same validation as a regular deployment. If validation errors are found, they are reported without making any changes to the Auth0 tenant.
```text
Validation Error: Rule "My Rule" - Names must be unique
Error: Configuration validation failed. No changes made.
```
--------------------------------
### Import with Dry Run (CLI)
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/docs/using-dry-run.md
Use the `--dry-run` flag with the `import` command to preview changes. This command simulates the deployment process without making any modifications to your Auth0 tenant.
```bash
a0deploy import --config_file=config.json --input_file=./tenant.yaml --dry-run
```
```bash
a0deploy import -c config.json -i ./tenant-directory --dry-run
```
--------------------------------
### `dump` function
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/docs/using-as-node-module.md
Fetches Auth0 tenant configurations to the local machine. Note that Marketplace Actions are not exported.
```APIDOC
## `dump` function
Fetches configurations from Auth0 tenant to the local machine.
> **Note**
> Marketplace Actions (including Auth0-owned marketplace Actions) are not exported. If your tenant uses marketplace Actions, their installation and configuration must be handled manually.
### Parameters
#### `format`
Options: `yaml` or `directory`. Determines the file format of the exported resource configuration files.
#### `output_folder`
Path. Specifies the target directory for configuration files to be written to.
#### `config`
Object. Configures behavior of utility. Refer to the list of [all configurable properties](./configuring-the-deploy-cli.md).
#### `config_file`
Path. Specifies the user-defined configuration file (config.json). Refer to the list of [all configurable properties](./configuring-the-deploy-cli.md).
#### `export_ids`
Boolean: When enabled, will export the identifier fields for each resource. Default: false.
#### `env`
Boolean. Indicates if the tool should ingest environment variables or not. Default: `false`.
#### `proxy_url`
A url for proxying requests. Only set this if you are behind a proxy.
### Example
```ts
import { dump } from 'auth0-deploy-cli';
dump({
output_folder: './local',
format: 'yaml',
config: {
AUTH0_DOMAIN: '',
AUTH0_CLIENT_ID: '',
AUTH0_CLIENT_SECRET: '',
},
})
.then(() => {
console.log('Auth0 configuration export successful');
})
.catch((err) => {
console.log('Error during Auth0 configuration export:', err);
});
```
```
--------------------------------
### Preview Only (CI/CD)
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/docs/using-dry-run.md
In CI/CD pipelines, use `--dry-run` to show the deployment plan and exit without applying changes. This is the default non-interactive behavior.
```bash
a0deploy import -c config.json -i tenant.yaml --dry-run
```
```yaml
- name: Preview Auth0 changes
run: a0deploy import -c config.json -i tenant.yaml --dry-run
```
--------------------------------
### Signup ID Screen Rendering Settings
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/docs/resource-specific-documentation.md
JSON configuration for defining screen rendering behavior and head tags for the signup-id prompt.
```json
{
"prompt": "signup-id",
"screen": "signup-id",
"rendering_mode": "advanced",
"context_configuration": ["branding.settings", "branding.themes.default"],
"default_head_tags_disabled": false,
"head_tags": [
{
"tag": "script",
"attributes": {
"src": "URL_TO_YOUR_ASSET",
"async": true,
"defer": true,
"integrity": ["ASSET_SHA"]
}
}
],
"filters": {
"match_type": "includes_any",
"clients": [
{
"id": "SeunfRe6p8EXxV6I0g9kMYdT1DxpfC38",
"metadata": { "key1": "value1" }
}
]
},
"use_page_template": false
}
```
--------------------------------
### Export Tenant Configuration to Directory
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/AGENTS.md
Command to export Auth0 tenant configuration to a local directory in directory format. Ensure the project is built first.
```bash
npm run build && node lib/index.js export -c config-dev.json -f directory -o ./local/
```
--------------------------------
### Use Keyword Replacement in tenant.json
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/docs/keyword-replacement.md
Demonstrates using `##ENVIRONMENT##` for literal replacement and `@@ALLOWED_LOGOUT_URLS@@` for stringified replacement of array values within a JSON configuration file.
```json
{
"friendly_name": "##ENVIRONMENT## tenant",
"allowed_logout_urls": "@@ALLOWED_LOGOUT_URLS@@"
}
```
--------------------------------
### Run All Tests
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/docs/how-to-contribute.md
Execute this command to run the entire test suite for the project.
```shell
npm run test
```
--------------------------------
### Import Auth0 Tenant Configuration from YAML
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/examples/yaml/README.md
This command imports your Auth0 tenant configuration from a specified YAML file. Ensure your `config.json` is correctly filled out before running the import.
```bash
a0deploy import -c config.json -i tenant.yaml
```
--------------------------------
### Export Auth0 tenant configurations
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/docs/using-as-cli.md
Commands for fetching configurations from an Auth0 tenant to a local machine using different formats and options.
```shell
# Fetching Auth0 tenant configuration in the YAML format
a0deploy export -c=config.json --format=yaml --output_folder=local
# Fetching Auth0 tenant configuration in directory (JSON) format
a0deploy export -c=config.json --format=directory --output_folder=local
# Fetching Auth0 tenant configurations with IDs of all assets
a0deploy export -c=config.json --format=yaml --output_folder=local --export_ids=true
# Fetching Auth0 tenant configurations including real secret values
a0deploy export -c=config.json --format=directory --output_folder=local --export_secrets
```
--------------------------------
### Import Tenant Configuration with Auth0 Deploy CLI
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/README.md
Use this command to import your Auth0 tenant configuration from local files. This requires a config file and the input file generated by the export command.
```shell
a0deploy import --config_file=config.json --input_file local/tenant.yaml
```
--------------------------------
### Export Tenant Configuration as YAML
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/AGENTS.md
Command to export Auth0 tenant configuration to a local directory in YAML format. Ensure the project is built first.
```bash
npm run build && node lib/index.js export -c config-dev.json -f yaml -o ./local-export/
```
--------------------------------
### Test CLI Locally
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/CONTRIBUTING.md
Build the project and run CLI commands locally to test changes.
```bash
# Build the project
npm run build
# Run CLI commands locally
node lib/index.js --help
node lib/index.js export --help
node lib/index.js import --help
```
```bash
# Example: Test export command
node lib/index.js export -c config.json -f yaml -o ./local-export/
```
```bash
# Example: Test import command
node lib/index.js import -c config.json -i ./local-export/tenant.yaml
```
--------------------------------
### Development Commands
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/CONTRIBUTING.md
Common commands for development, including watch mode, testing, linting, formatting, and building.
```bash
# Development with watch mode
npm run dev
```
```bash
# Run tests
npm test
```
```bash
# Run single test file
npx ts-mocha test/path/to/specific.test.ts
```
```bash
# Lint and format
npm run lint:fix
npm run format
```
```bash
# Check TypeScript compilation
npx tsc --noEmit
```
```bash
# Run CLI locally for testing
npm run build && node lib/index.js --help
```
--------------------------------
### Configure Included Connections via Environment Variables
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/docs/configuring-the-deploy-cli.md
Pass the included connections as a JSON array string when using environment variables.
```shell
# JSON array format
export AUTH0_INCLUDED_CONNECTIONS='["github","google-oauth2"]'
# Or as a single-line array
export AUTH0_INCLUDED_CONNECTIONS='["github"]'
```
--------------------------------
### Configure Resource Server
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/docs/resource-specific-documentation.md
Define a resource server with proof of possession settings.
```yaml
resourceServers:
- name: My API
identifier: https://api.example.com
proof_of_possession:
mechanism: dpop
required: true
required_for: public_clients
```
```json
{
"name": "My API",
"identifier": "https://api.example.com",
"proof_of_possession": {
"mechanism": "mtls",
"required": true,
"required_for": "all_clients"
}
}
```
--------------------------------
### Define Connection Profiles in YAML
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/docs/resource-specific-documentation.md
Use the connectionProfiles array in your tenant.yaml file to define multiple profiles with strategy overrides.
```yaml
# Contents of ./tenant.yaml
connectionProfiles:
- name: 'Enterprise SSO Profile'
organization:
show_as_button: 'required'
assign_membership_on_login: 'required'
connection_name_prefix_template: 'org-{organization_name}'
enabled_features:
- scim
- universal_logout
strategy_overrides:
samlp:
enabled_features:
- universal_logout
oidc:
enabled_features:
- scim
- universal_logout
- name: 'Basic Connection Profile'
organization:
show_as_button: 'optional'
assign_membership_on_login: 'optional'
enabled_features:
- scim
```
--------------------------------
### Configure Action Modules in YAML
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/docs/resource-specific-documentation.md
Define reusable action modules, their dependencies, and secrets in the tenant.yaml file.
```yaml
# Contents of ./tenant.yaml
actionModules:
- name: auth-helper
code: ./action-modules/auth-helper/code.js
dependencies:
- name: axios
version: 1.6.0
- name: jsonwebtoken
version: 9.0.0
secrets:
- name: JWT_SECRET
value: ##JWT_SECRET##
- name: notification-helper
code: ./action-modules/notification-helper/code.js
dependencies:
- name: uuid
version: 9.0.0
secrets: []
```
--------------------------------
### Run Tests and Linters
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/AGENTS.md
Commands for running unit tests, end-to-end tests (both as a node module and as a CLI), and the linter.
```bash
# Run unit tests
npm test
# Run E2E tests (requires Auth0 tenant)
npm run test:e2e:node-module
npm run test:e2e:cli
# Run linter
npm run lint
```
--------------------------------
### Export Tenant Configuration with Auth0 Deploy CLI
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/README.md
Use this command to export your Auth0 tenant configuration to YAML format. Ensure environment variables like AUTH0_DOMAIN, AUTH0_CLIENT_ID, and AUTH0_CLIENT_SECRET are set.
```shell
a0deploy export --format=yaml --output_folder=local
```
--------------------------------
### Dry Run with Apply (CI/CD)
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/docs/using-dry-run.md
To show the plan and automatically apply changes without prompting during a dry run in CI/CD, use both `--dry-run` and `--apply` flags. This allows for automated deployments after previewing.
```bash
a0deploy import -c config.json -i tenant.yaml --dry-run --apply
```
--------------------------------
### Environment Variable Replacement in Auth0 Tenant Config
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/examples/yaml/README.md
Demonstrates using `@@key@@` (stringified) and `##key##` (literal) for environment variable replacements in Auth0 tenant configuration files. This allows for deploying the same configuration across different environments by injecting environment-specific values.
```json
{
...
"callbacks": [
"##ENVIRONMENT_URL##/auth/callback"
],
"jwt_configuration": {
"lifetime_in_seconds": @@JWT_TIMEOUT@@,
"secret_encoded": true
}
...
```
```json
"AUTH0_KEYWORD_REPLACE_MAPPINGS": {
"ENVIRONMENT_URL": "http://dev.fabrikam.com",
"JWT_TIMEOUT": 120,
...
}
```
```json
"AUTH0_KEYWORD_REPLACE_MAPPINGS": {
"ENVIRONMENT_URL": "http://fabrikam.com",
"JWT_TIMEOUT": 3600,
...
}
```
--------------------------------
### Define Database Connection Scripts in YAML
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/docs/resource-specific-documentation.md
Configure custom scripts in tenant.yaml by providing relative paths to the JavaScript files.
```yaml
# Contents of ./tenant.yaml
databases:
- name: Username-Password-Authentication
# ...
options:
# ...
customScripts:
change_password: ./databases/Username-Password-Authentication/change_password.js
create: ./databases/Username-Password-Authentication/create.js
delete: ./databases/Username-Password-Authentication/delete.js
get_user: ./databases/Username-Password-Authentication/get_user.js
login: ./databases/Username-Password-Authentication/login.js
verify: ./databases/Username-Password-Authentication/verify.js
```
--------------------------------
### Configure Supplemental Signals
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/docs/resource-specific-documentation.md
Enable Akamai header processing for security signals via tenant configuration.
```yaml
# Contents of ./tenant.yaml
supplementalSignals:
akamai_enabled: true
```
```json
{
"akamai_enabled": true
}
```
--------------------------------
### Configure Phone Providers in YAML
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/docs/resource-specific-documentation.md
Use the phoneProviders key in tenant.yaml to define Twilio settings, utilizing the ##TWILIO_AUTH_TOKEN## placeholder for credentials.
```yaml
# Contents of ./tenant.yaml
phoneProviders:
- name: twilio
configuration:
sid: 'twilio_sid'
default_from: '+1234567890'
delivery_methods:
- text
- voice
disabled: false
credentials:
auth_token: '##TWILIO_AUTH_TOKEN##'
```
--------------------------------
### Configure Branding in Directory Mode
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/docs/resource-specific-documentation.md
JSON structure for branding settings when using directory-based configuration.
```json
{
"colors": {
"page_background": "#FF4F40",
"primary": "#2A2E35"
},
"favicon_url": "https://example.com/favicon.png",
"font": {
"url": "https://example.com/font.woff"
},
"logo_url": "https://example.com/logo.png"
}
```
--------------------------------
### Run Tests
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/CONTRIBUTING.md
Execute all unit tests to ensure code quality and functionality.
```bash
# Unit tests (required)
npm test
```
--------------------------------
### Configure Event Streams in Directory
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/docs/resource-specific-documentation.md
Define individual event streams as separate JSON files within the event-streams directory.
```json
{
"name": "My Webhook Stream",
"status": "enabled",
"subscriptions": [{ "event_type": "user.created" }],
"destination": {
"type": "webhook",
"configuration": {
"webhook_endpoint": "https://example.com/events",
"webhook_authorization": {
"method": "bearer"
}
}
}
}
```
--------------------------------
### Configure Universal Login via YAML
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/docs/resource-specific-documentation.md
Defines the folder structure and tenant.yaml configuration for managing Universal Login pages in YAML mode.
```text
Folder structure when in YAML mode.
./pages/
/error_page.html
/guardian_multifactor.html
/login.html
/password_reset.html
./tenant.yaml
```
```yaml
# Contents of ./tenant.yaml
pages:
- name: error_page
html: ./pages/error_page.html
show_log_link: false
url: https://mycompany.org/error
- name: guardian_multifactor
enabled: true
html: ./pages/guardian_multifactor.html
- name: login
enabled: false
html: ./pages/login.html
- name: password_reset
enabled: true
html: ./pages/password_reset.html
```
--------------------------------
### Dump Auth0 Configuration to Local Machine
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/docs/using-as-node-module.md
Use the `dump` function to fetch configurations from your Auth0 tenant and save them locally. Specify the output folder, desired format (YAML or directory), and provide authentication credentials.
```typescript
import { dump } from 'auth0-deploy-cli';
dump({
output_folder: './local',
format: 'yaml',
config: {
AUTH0_DOMAIN: '',
AUTH0_CLIENT_ID: '',
AUTH0_CLIENT_SECRET: '',
},
})
.then(() => {
console.log('Auth0 configuration export successful');
})
.catch((err) => {
console.log('Error during Auth0 configuration export:', err);
});
```
--------------------------------
### Define configuration in config.json
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/docs/configuring-the-deploy-cli.md
A standard JSON file used to store tenant credentials and tool behavior settings.
```json
{
"AUTH0_DOMAIN": "",
"AUTH0_CLIENT_ID": "",
"AUTH0_ALLOW_DELETE": false
}
```
--------------------------------
### Environment-Specific Configuration with Keyword Replacement
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/docs/multi-environment-workflow.md
Use a JSON configuration file for a specific environment (e.g., development) to define Auth0 settings and dynamic values. The `AUTH0_KEYWORD_REPLACE_MAPPINGS` property allows for environment-specific substitutions, such as allowed origins.
```json
{
"AUTH0_DOMAIN": "travel0-dev.us.auth0.com",
"AUTH0_CLIENT_ID": "PdwQpGy62sHcsV6ufZNEVrV4GDlDhm74",
"AUTH0_ALLOW_DELETE": true,
"AUTH0_KEYWORD_REPLACE_MAPPINGS": {
"ENV": "dev",
"ALLOWED_ORIGINS": ["http://localhost:3000", "http://dev.travel0.com"]
}
}
```
--------------------------------
### Google Workspace Directory Provisioning Configuration
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/docs/resource-specific-documentation.md
Configuration for Google Workspace directory provisioning, supporting both YAML and JSON formats for connection management.
```yaml
connections:
- name: google-workspace
strategy: google-apps
options:
domain: example.com
tenant_domain: example.com
client_id: 'some_client_id'
client_secret: 'some_client_secret'
api_enable_groups: true
api_enable_users: true
directory_provisioning_configuration:
mapping:
- auth0: email
idp: mail
- auth0: name
idp: displayName
synchronize_automatically: false
synchronize_groups: selected
synchronized_groups:
- id: 'group-id-1'
- id: 'group-id-2'
```
```json
{
"name": "google-apps-directory-provisioning",
"strategy": "google-apps",
"enabled_clients": ["My SPA"],
"options": {
"domain": "example.com",
"tenant_domain": "example.com",
"client_id": "some_client_id",
"client_secret": "some_client_secret",
"api_enable_groups": true,
"api_enable_users": true
},
"directory_provisioning_configuration": {
"mapping": [
{ "auth0": "email", "idp": "mail" },
{ "auth0": "name", "idp": "displayName" }
],
"synchronize_automatically": false,
"synchronize_groups": "selected",
"synchronized_groups": [{ "id": "group-id-1" }, { "id": "group-id-2" }]
}
}
```
--------------------------------
### Configure Universal Login via Directory
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/docs/resource-specific-documentation.md
Defines the folder structure and individual JSON configuration files for managing Universal Login pages in directory mode.
```text
Folder structure when in directory mode.
./pages/
./error_page.html
./error_page.json
./guardian_multifactor.html
./guardian_multifactor.json
./login.html
./login.json
./password_reset.html
./password_reset.json
```
```json
{
"name": "login",
"enabled": false,
"html": "./login.html"
}
```
```json
{
"html": "./error_page.html",
"show_log_link": false,
"url": "https://mycompany.org/error",
"name": "error_page"
}
```
```json
{
"enabled": true,
"html": "./guardian_multifactor.html",
"name": "guardian_multifactor"
}
```
```json
{
"enabled": true,
"html": "./password_reset.html",
"name": "password_reset"
}
```
--------------------------------
### Configure Branding in YAML
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/docs/resource-specific-documentation.md
Defines branding colors, assets, and universal login templates within a YAML configuration file.
```yaml
branding:
colors:
page_background: '#FF4F40'
primary: '#2A2E35'
favicon_url: https://example.com/favicon.png
font:
url: https://example.com/font.woff
logo_url: https://example.com/logo.png
templates:
- template: universal_login
body: ./branding_templates/universal_login.html
```
--------------------------------
### Configure Action Module Metadata
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/docs/resource-specific-documentation.md
Define individual action module metadata in a JSON file.
```json
{
"name": "auth-helper",
"code": "./action-modules/auth-helper/code.js",
"dependencies": [
{
"name": "axios",
"version": "1.6.0"
},
{
"name": "jsonwebtoken",
"version": "9.0.0"
}
],
"secrets": [
{
"name": "JWT_SECRET",
"value": "##JWT_SECRET##"
}
]
}
```
--------------------------------
### Define Database Connection Scripts in JSON
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/docs/resource-specific-documentation.md
Configure custom scripts within a database.json file when using directory mode.
```json
{
"options": {
"customScripts": {
"change_password": "./change_password.js",
"create": "./create.js",
"delete": "./delete.js",
"get_user": "./get_user.js",
"login": "./login.js",
"verify": "./verify.js"
}
}
}
```
--------------------------------
### Configure Risk Assessments in YAML
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/docs/resource-specific-documentation.md
Define risk assessment settings within the tenant.yaml file.
```yaml
# Contents of ./tenant.yaml
riskAssessment:
settings:
enabled: true
new_device:
remember_for: 30
```
--------------------------------
### Define Self-Service Profiles in JSON
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/docs/resource-specific-documentation.md
Individual JSON files for specific profiles. Use these files when deploying in directory mode.
```json
{
"name": "Enterprise SSO Profile",
"description": "Self-service SSO for enterprise customers",
"allowed_strategies": ["oidc", "samlp", "okta"],
"user_attributes": [
{
"name": "email",
"description": "Email of the User",
"is_optional": false
},
{
"name": "name",
"description": "Name of the User",
"is_optional": true
}
],
"branding": {
"logo_url": "https://example.com/logo.png",
"colors": {
"primary": "#19aecc"
}
},
"customText": {
"en": {
"get-started": {
"introduction": "Welcome! With only a few steps
you will be able to setup your new connection."
}
}
}
}
```
```json
{
"name": "Simple SSO Profile",
"description": "Basic SSO profile",
"user_attribute_profile_id": "My User Attribute Profile",
"allowed_strategies": ["google-apps", "adfs"]
}
```
--------------------------------
### Configure Risk Assessments in Directory Mode
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/docs/resource-specific-documentation.md
Define risk assessment settings in a dedicated JSON file within the project directory.
```json
{
"settings": {
"enabled": true
},
"new_device": {
"remember_for": 30
}
}
```
--------------------------------
### Configure Included Connections via JSON
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/docs/configuring-the-deploy-cli.md
Define specific connections to be managed by the Deploy CLI using a JSON configuration object.
```json
{
"AUTH0_INCLUDED_CONNECTIONS": ["github", "google-oauth2"]
}
```
--------------------------------
### Configure Phone Providers in JSON
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/docs/resource-specific-documentation.md
Define phone provider settings within a JSON array structure.
```json
[
{
"name": "twilio",
"disabled": true,
"configuration": {
"sid": "twilio_sid",
"default_from": "+1234567890",
"delivery_methods": ["text", "voice"]
},
"credentials": {
"auth_token": "##TWILIO_AUTH_TOKEN##"
}
}
]
```
--------------------------------
### Run All E2E Tests with Recordings
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/test/e2e/e2e_recordings.md
Execute all E2E tests using existing recordings. This command is used for running tests in a production-like environment without making actual API calls.
```shell
AUTH0_HTTP_RECORDINGS="lockdown" npm run test:e2e:node-module
```
--------------------------------
### Dry Run Preview Output
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/docs/using-dry-run.md
The dry run mode displays a detailed preview of proposed changes in a table format, including resource type, status (CREATE, UPDATE, DELETE), and name/identifier. It also indicates if deletions require `AUTH0_ALLOW_DELETE` to be enabled.
```text
Auth0 Deploy CLI - Dry Run Preview
Tenant: example-tenant.auth0.com
Input: local/tenant.yaml
Simulating deployment... The following changes are proposed:
┌─────────────┬─────────┬──────────────────────────────────┐
│ Resource │ Status │ Name / Identifier │
├─────────────┼─────────┼──────────────────────────────────┤
│ Actions │ CREATE │ Post-Login User Enrichment │
│ │ CREATE │ Pre-Registration Validation │
│ │ DELETE* │ Deprecated Action │
│ Clients │ CREATE │ New SPA Application │
│ │ UPDATE │ Existing M2M Application │
│ Connections │ UPDATE │ Username-Password-Authentication │
└─────────────┴─────────┴──────────────────────────────────┘
* Requires AUTH0_ALLOW_DELETE to be enabled
Dry Run completed successfully. No changes have been made to your Auth0 tenant.
┌ dry-run
│
◆ What would you like to do?
│ ○ Apply changes
│ ○ Export changes in a file (No Apply)
│ ○ Exit
└
```
--------------------------------
### Dry Run Output: No Changes Detected
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/docs/using-dry-run.md
This output indicates that the configuration in your local files matches the current state of your Auth0 tenant. No modifications are needed.
```text
Auth0 Deploy CLI - Dry Run Preview
Tenant: example-tenant.auth0.com
Input: ./tenant-config/
Simulating deployment... The following changes are proposed:
No changes detected.
Dry Run completed successfully. No changes have been made to your Auth0 tenant.
```
--------------------------------
### Configure Event Streams in YAML
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/docs/resource-specific-documentation.md
Define event streams within the tenant YAML configuration file.
```yaml
# Contents of ./tenant.yaml
eventStreams:
- name: My Webhook Stream
status: enabled
subscriptions:
- event_type: user.created
- event_type: user.deleted
destination:
type: webhook
configuration:
webhook_endpoint: https://example.com/events
webhook_authorization:
method: bearer
```
--------------------------------
### Define Keyword Replace Mappings
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/docs/configuring-the-deploy-cli.md
Map keywords to values for dynamic replacement during deployment.
```json
{
"ENVIRONMENT": "DEV",
"ALLOWED_ORIGINS": ["https://dev.test-site.com", "localhost"]
}
```
--------------------------------
### Configure Email Templates in tenant.yaml
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/docs/resource-specific-documentation.md
Defines email templates within the tenant.yaml file, referencing external HTML files for the body content.
```yaml
# Contents of ./tenant.yaml
emailTemplates:
- template: 'verify_email'
enabled: true
syntax: 'liquid'
from: 'test@email.com'
subject: 'something'
body: 'emailTemplates/change_email.html'
- template: 'welcome_email'
enabled: true
syntax: 'liquid'
from: 'test@email.com'
subject: 'something'
body: 'emailTemplates/change_email.html'
- template: 'password_reset'
enabled: true
syntax: 'liquid'
from: 'test@email.com'
subject: 'something'
body: 'emailTemplates/change_email.html'
- template: 'reset_email_by_code'
enabled: true
syntax: 'liquid'
from: 'test@email.com'
subject: 'something'
body: 'emailTemplates/change_email.html'
```
--------------------------------
### Structure NetworkACLs in Directory Mode
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/docs/resource-specific-documentation.md
Organize rules into a networkACLs folder where each file represents a single rule configuration.
```text
./networkACLs/
./Allow Specific Countries-p-2.json
./Redirect Specific User Agents-p-3.json
```
--------------------------------
### Export Tenant Configuration to Directory
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/examples/directory/README.md
Use this command to export your current Auth0 tenant configuration into a specified directory structure. The `AUTH0_EXPORT_IDENTIFIERS` config value or `--export_ids` option can be used to include identifier fields, which may prevent direct import later. Note that some settings like emailProvider credentials cannot be exported and may require manual updates to `tenant.yaml` upon import.
```bash
a0deploy export -c config.json -f directory -o path/to/export
```
--------------------------------
### Universal Login Template Metadata
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/docs/resource-specific-documentation.md
JSON configuration file linking a template name to its HTML body file.
```json
{
"template": "universal_login",
"body": "./universal_login.html"
}
```
--------------------------------
### Test CLI Export Command
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/AGENTS.md
Use this command to test the CLI's export functionality, specifying a configuration file and an output folder.
```bash
node lib/index.js export -c config.json --output_folder ./test-output
```
--------------------------------
### Configure Online Refresh Tokens
Source: https://github.com/auth0/auth0-deploy-cli/blob/master/docs/resource-specific-documentation.md
Enable online refresh tokens and ephemeral session support for a resource server.
```yaml
resourceServers:
- name: My API
identifier: https://api.example.com
allow_online_access: true
allow_online_access_with_ephemeral_sessions: false
```
```json
{
"name": "My API",
"identifier": "https://api.example.com",
"allow_online_access": true,
"allow_online_access_with_ephemeral_sessions": false
}
```