Skip to content

feat: Support for Multiple Custom Domains #1113

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Jul 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions examples/directory/custom-domains/custom-domains.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[
{
"domain": "my_domain.com",
"type": "auth0_managed_certs",
"tls_policy": "recommended",
"domain_metadata": {
"myKey": "value"
}
}
]
8 changes: 8 additions & 0 deletions examples/yaml/tenant.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -272,3 +272,11 @@ networkACLs:
scope: 'authentication'
match:
geo_country_codes: ['US', 'CA']

customDomains:
- domain: my_domain.com
type: auth0_managed_certs
tls_policy: 'recommended'
domain_metadata:
myKey: value

68 changes: 44 additions & 24 deletions src/tools/auth0/handlers/customDomains.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { CustomDomain } from 'auth0';
import DefaultAPIHandler, { order } from './default';
import { Asset, Assets } from '../../../types';
import log from '../../../logger';

export const schema = {
type: 'array',
Expand All @@ -18,6 +19,22 @@ export const schema = {
status: { type: 'string', enum: ['pending_verification', 'ready', 'disabled', 'pending'] },
type: { type: 'string', enum: ['auth0_managed_certs', 'self_managed_certs'] },
verification: { type: 'object' },
tls_policy: {
type: 'string',
description: 'Custom domain TLS policy. Must be `recommended`, includes TLS 1.2.',
defaultValue: 'recommended',
},
domain_metadata: {
type: 'object',
description: 'Domain metadata associated with the custom domain.',
defaultValue: undefined,
maxProperties: 10,
},
verification_method: {
type: 'string',
description: 'Custom domain verification method. Must be `txt`.',
defaultValue: 'txt',
},
},
required: ['domain', 'type'],
},
Expand All @@ -31,10 +48,21 @@ export default class CustomDomainsHadnler extends DefaultAPIHandler {
...config,
type: 'customDomains',
id: 'custom_domain_id',
identifiers: ['domain'],
stripCreateFields: ['status', 'primary', 'verification'],
identifiers: ['custom_domain_id', 'domain'],
stripCreateFields: ['status', 'primary', 'verification', 'certificate'],
stripUpdateFields: [
'status',
'primary',
'verification',
'type',
'domain',
'verification_method',
'certificate',
],
functions: {
delete: (args) => this.client.customDomains.delete({ id: args.custom_domain_id }),
update: (args, data) =>
this.client.customDomains.update({ id: args.custom_domain_id }, data),
},
});
}
Expand Down Expand Up @@ -71,29 +99,21 @@ export default class CustomDomainsHadnler extends DefaultAPIHandler {
const { customDomains } = assets;

if (!customDomains) return;
const changes = await this.calcChanges(assets).then((changes) => {
const changesWithoutUpdates = {
...changes,
create: changes.create.map((customDomainToCreate) => {
const newCustomDomain = { ...customDomainToCreate };
if (customDomainToCreate.custom_client_ip_header === null) {
delete newCustomDomain.custom_client_ip_header;
}

return newCustomDomain;
}),
delete: changes.del.map((deleteToMake) => {
const deleteWithSDKCompatibleID = {
...deleteToMake,
id: deleteToMake.custom_domain_id,
};
delete deleteWithSDKCompatibleID['custom_domain_id'];
return deleteWithSDKCompatibleID;
}),
update: [], //Do not perform custom domain updates because not supported by SDK
};
return changesWithoutUpdates;
});
// Deprecation warnings for custom domains
if (customDomains.some((customDomain) => customDomain.primary != null)) {
log.warn(
'The "primary" field is deprecated and may be removed in future versions for "customDomains"'
);
}

if (customDomains.some((customDomain) => 'verification_method' in customDomain)) {
log.warn(
'The "verification_method" field is deprecated and may be removed in future versions for "customDomains"'
);
}

const changes = await this.calcChanges(assets);

await super.processChanges(assets, changes);
}
Expand Down
Loading