-
Notifications
You must be signed in to change notification settings - Fork 163
[Don't merge] 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
base: master
Are you sure you want to change the base?
Changes from all commits
4c073f3
b2c007b
3088a68
bd88d81
d841edb
a2f0531
dfc1b66
0e4939b
c4804b3
069b11e
1e33910
0a92dfc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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" | ||
} | ||
} | ||
] |
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', | ||
|
@@ -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'], | ||
}, | ||
|
@@ -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', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I also see another field name There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, this was not added in the previous implementation, but we can add it now. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I saw it being added in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, because the schema is used for input validation, |
||
'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), | ||
}, | ||
}); | ||
} | ||
|
@@ -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); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we include tls_policy too..?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated