This Terraform module configures Auth0 resources for authentication and authorization for the Nuon BYOC (Bring Your Own Cloud) applications. It creates and manages:
- A SPA Application for web interfaces
- A Native Application for CLI tools
- An API Resource Server for backend services
- A Custom Action to add email claims to access tokens
- An Auth0 account
- A Management API client with sufficient permissions to create and manage Auth0 resources
.
├── main.tf # Resources definition
├── variables.tf # Input variables
├── outputs.tf # Output values
├── versions.tf # Version constraints
├── README.md # Project documentation
├── MODULE_README.md # Detailed module documentation
└── examples/
└── basic/ # Basic usage example
├── main.tf
├── variables.tf
└── terraform.tfvars.example
Before using this module, you need to set up a properly scoped Auth0 Management API client:
-
Optionally create a new tenant in Auth0 where you will house the Nuon applications
-
Go to Applications > Create Application > Machine to Machine
-
Select the Auth0 Management API
-
Click on the API tab to configure permissions
-
Configure the following permissions (use the filter to find each category):
Clients permissions:
Create:clients
Read:clients
Update:clients
Delete:clients
Client Keys permissions:
Create:client_keys
Client Credentials permissions:
Create:client_credentials
Read:client_credentials
Update:client_credentials
Delete:client_credentials
Resource Servers permissions:
Create:resource_servers
Read:resource_servers
Update:resource_servers
Delete:resource_servers
Actions permissions:
Create:actions
Read:actions
Update:actions
Delete:actions
-
After creating the application, collect the following values for your Terraform configuration:
auth0_domain
- Your Auth0 tenant domain (e.g.,your-tenant-name.us.auth0.com
)auth0_mgmt_client_id
- Client ID of the Management API clientauth0_mgmt_client_secret
- Client Secret of the Management API client
module "auth0_provider" {
source = "path/to/auth0-provider"
# Auth0 Provider Configuration
auth0_domain = var.auth0_domain
auth0_mgmt_client_id = var.auth0_mgmt_client_id
auth0_mgmt_client_secret = var.auth0_mgmt_client_secret
# Application Configuration
install_name = "my-app" # Optional: defaults to "BYOC"
public_domain = "app.example.com"
# URL Configuration - Optional
# These are automatically derived from public_domain if not specified:
# callback_url = "https://app.example.com/api/auth/callback"
# logout_url = "https://app.example.com"
# web_origin = "https://app.example.com"
}
Name | Description | Type | Default | Required |
---|---|---|---|---|
auth0_domain | Your Auth0 domain (e.g., your-tenant.auth0.com) | string | - | yes |
auth0_mgmt_client_id | Auth0 Management API Client ID | string | - | yes |
auth0_mgmt_client_secret | Auth0 Management API Client Secret | string | - | yes |
install_name | Installation name used as a prefix for Auth0 resources | string | "BYOC" |
no |
public_domain | Public domain for the installation | string | - | yes |
callback_url | The callback URL for the SPA application (defaults to https://[public_domain]/api/auth/callback if not specified) | string | null |
no |
logout_url | The logout URL for the SPA application (defaults to https://[public_domain] if not specified) | string | null |
no |
web_origin | The web origin for CORS (domain only, no paths) (defaults to https://[public_domain] if not specified) | string | null |
no |
- auth0_domain: This is your Auth0 tenant domain (e.g.,
your-tenant.us.auth0.com
). You must create this tenant in Auth0 before using this module. - auth0_mgmt_client_id and auth0_mgmt_client_secret: These are credentials for an Auth0 Management API client that has permissions to create and manage resources in your Auth0 tenant.
- install_name: This is used as a prefix for all Auth0 resources created by this module. Default is
"BYOC"
. - public_domain: This is the only required application configuration parameter. It's used to configure the API identifier and automatically construct all URL values.
- URL variables: In a default installation, you don't need to specify
callback_url
,logout_url
, orweb_origin
. These are automatically derived frompublic_domain
in the module'smain.tf
file. You only need to provide these if you want to use custom URLs different from the defaults.
The Auth0 provider must be configured in your root module:
provider "auth0" {
domain = var.auth0_domain
client_id = var.auth0_mgmt_client_id
client_secret = var.auth0_mgmt_client_secret
}
See the examples
directory for working examples of how to use this module.
-
Navigate to the example directory:
cd examples/basic
-
Copy the example variables file and edit it with your Auth0 credentials:
cp terraform.tfvars.example terraform.tfvars
-
Initialize and apply the Terraform configuration:
terraform init terraform apply
- Terraform >= 1.0.0
- Auth0 Provider ~> 1.21.0
- An Auth0 account
- A Management API client with sufficient permissions
This module is licensed under the MIT License.