Skip to content

Commit 9aed335

Browse files
authored
feat: Support for Multiple Custom Domains (#1113)
* feat: add deprecation warnings for custom domain fields and enhance schema * feat: remove deprecation warning for verification_method field in custom domains * feat: add custom domains configuration with auth0 managed certificates * Fix comment formatting and add update tests for customDomains handler - Standardize TypeScript ignore comments with proper spacing - Standardize inline comment formatting with consistent spacing - Add comprehensive test coverage for custom domain update functionality * feat: add tls_policy to custom domains configuration * feat: add verification_method to custom domains schema
1 parent 8f3014c commit 9aed335

File tree

4 files changed

+324
-35
lines changed

4 files changed

+324
-35
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[
2+
{
3+
"domain": "my_domain.com",
4+
"type": "auth0_managed_certs",
5+
"tls_policy": "recommended",
6+
"domain_metadata": {
7+
"myKey": "value"
8+
}
9+
}
10+
]

examples/yaml/tenant.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,3 +272,11 @@ networkACLs:
272272
scope: 'authentication'
273273
match:
274274
geo_country_codes: ['US', 'CA']
275+
276+
customDomains:
277+
- domain: my_domain.com
278+
type: auth0_managed_certs
279+
tls_policy: 'recommended'
280+
domain_metadata:
281+
myKey: value
282+

src/tools/auth0/handlers/customDomains.ts

Lines changed: 44 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { CustomDomain } from 'auth0';
22
import DefaultAPIHandler, { order } from './default';
33
import { Asset, Assets } from '../../../types';
4+
import log from '../../../logger';
45

56
export const schema = {
67
type: 'array',
@@ -18,6 +19,22 @@ export const schema = {
1819
status: { type: 'string', enum: ['pending_verification', 'ready', 'disabled', 'pending'] },
1920
type: { type: 'string', enum: ['auth0_managed_certs', 'self_managed_certs'] },
2021
verification: { type: 'object' },
22+
tls_policy: {
23+
type: 'string',
24+
description: 'Custom domain TLS policy. Must be `recommended`, includes TLS 1.2.',
25+
defaultValue: 'recommended',
26+
},
27+
domain_metadata: {
28+
type: 'object',
29+
description: 'Domain metadata associated with the custom domain.',
30+
defaultValue: undefined,
31+
maxProperties: 10,
32+
},
33+
verification_method: {
34+
type: 'string',
35+
description: 'Custom domain verification method. Must be `txt`.',
36+
defaultValue: 'txt',
37+
},
2138
},
2239
required: ['domain', 'type'],
2340
},
@@ -31,10 +48,21 @@ export default class CustomDomainsHadnler extends DefaultAPIHandler {
3148
...config,
3249
type: 'customDomains',
3350
id: 'custom_domain_id',
34-
identifiers: ['domain'],
35-
stripCreateFields: ['status', 'primary', 'verification'],
51+
identifiers: ['custom_domain_id', 'domain'],
52+
stripCreateFields: ['status', 'primary', 'verification', 'certificate'],
53+
stripUpdateFields: [
54+
'status',
55+
'primary',
56+
'verification',
57+
'type',
58+
'domain',
59+
'verification_method',
60+
'certificate',
61+
],
3662
functions: {
3763
delete: (args) => this.client.customDomains.delete({ id: args.custom_domain_id }),
64+
update: (args, data) =>
65+
this.client.customDomains.update({ id: args.custom_domain_id }, data),
3866
},
3967
});
4068
}
@@ -71,29 +99,21 @@ export default class CustomDomainsHadnler extends DefaultAPIHandler {
7199
const { customDomains } = assets;
72100

73101
if (!customDomains) return;
74-
const changes = await this.calcChanges(assets).then((changes) => {
75-
const changesWithoutUpdates = {
76-
...changes,
77-
create: changes.create.map((customDomainToCreate) => {
78-
const newCustomDomain = { ...customDomainToCreate };
79-
if (customDomainToCreate.custom_client_ip_header === null) {
80-
delete newCustomDomain.custom_client_ip_header;
81-
}
82102

83-
return newCustomDomain;
84-
}),
85-
delete: changes.del.map((deleteToMake) => {
86-
const deleteWithSDKCompatibleID = {
87-
...deleteToMake,
88-
id: deleteToMake.custom_domain_id,
89-
};
90-
delete deleteWithSDKCompatibleID['custom_domain_id'];
91-
return deleteWithSDKCompatibleID;
92-
}),
93-
update: [], //Do not perform custom domain updates because not supported by SDK
94-
};
95-
return changesWithoutUpdates;
96-
});
103+
// Deprecation warnings for custom domains
104+
if (customDomains.some((customDomain) => customDomain.primary != null)) {
105+
log.warn(
106+
'The "primary" field is deprecated and may be removed in future versions for "customDomains"'
107+
);
108+
}
109+
110+
if (customDomains.some((customDomain) => 'verification_method' in customDomain)) {
111+
log.warn(
112+
'The "verification_method" field is deprecated and may be removed in future versions for "customDomains"'
113+
);
114+
}
115+
116+
const changes = await this.calcChanges(assets);
97117

98118
await super.processChanges(assets, changes);
99119
}

0 commit comments

Comments
 (0)