Skip to content

Commit

Permalink
Extensibility support email provider (#1016)
Browse files Browse the repository at this point in the history
* feat: Add default credentials support
for Azure and MS365 email providers

* fix: Remove unnecessary logging for disabled email provider

* update to auth0:4.16.0

* docs: Update migration guide for Auth0 v4.x changes
  • Loading branch information
kushalshit27 authored Jan 20, 2025
1 parent ee9e231 commit 42630e7
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 24 deletions.
24 changes: 11 additions & 13 deletions docs/v8_MIGRATION_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
Guide to migrating from `7.x` to `8.x`

- [General](#general)
- [Node 18 or newer is required](#node-18-or-newer-is-required)
- [Auth0 V4 Migration Guide](https://github.com/auth0/node-auth0/blob/master/v4_MIGRATION_GUIDE.md)
- [Node 18 or newer is required](#node-18-or-newer-is-required)
- [Auth0 V4 Migration Guide](https://github.com/auth0/node-auth0/blob/master/v4_MIGRATION_GUIDE.md)
- [Management Resources](#management-resources)
- [EmailProvider](#emailProvider)
- [Migrations](#migrations)
- [EmailProvider](#emailProvider)
- [Migrations](#migrations)

## General

Expand All @@ -18,29 +18,27 @@ Node 18 LTS and newer LTS releases are supported.
## Management Resources

| Resource | Change | Description |
|---------------|------------------|-----------------------------------------------|
| ------------- | ---------------- | --------------------------------------------- |
| emailProvider | delete operation | Delete operation is deprecated on auth0 `4.x` |
| migrations | removed support | Not supported on auth0 `4.x` |

#### Note: Other resources from `7.x` are not affected and no changes are required.

#### emailProvider
#### emailProvider :

The `delete` operation on the `emailProvider` resource will disable the email provider instead of deleting it.
This is because the email provider deletion operation is deprecated on auth0 `4.x`. User can disable the email provider
This is because the email provider deletion operation is not supported on auth0 `4.x`. User can disable the email provider
by email provider setting the `enabled` property to `false` from the configuration file.

```yaml
emailProvider:
# other properties
enabled: false
emailProvider:
# other properties
enabled: false
```
Rest of the operations on emailProvider resource will work the same as `7.x`.

#### migrations
#### migrations :

The `migrations` resource is not supported on auth0 `4.x`. It's recommended to remove the `migrations` resource from the
configuration file. If it's not removed, the deploy CLI will ignore the `migrations` resource for operations.


14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"homepage": "https://github.com/auth0/auth0-deploy-cli#readme",
"dependencies": {
"ajv": "^6.12.6",
"auth0": "^4.15.0",
"auth0": "^4.16.0",
"dot-prop": "^5.2.0",
"fs-extra": "^10.1.0",
"global-agent": "^3.0.0",
Expand Down
17 changes: 17 additions & 0 deletions src/context/defaults.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// eslint-disable-next-line import/prefer-default-export
export function emailProviderDefaults(emailProvider) {
// eslint-disable-line
const updated = { ...emailProvider };
Expand Down Expand Up @@ -33,5 +34,21 @@ export function emailProviderDefaults(emailProvider) {
};
}

if (name === 'azure_cs') {
updated.credentials = {
connectionString: '##AZURE_CS_CONNECTION_KEY##',
...(updated.credentials || {}),
};
}

if (name === 'ms365') {
updated.credentials = {
tenantId: '##MS365_TENANT_ID##',
clientId: '##MS365_CLIENT_ID##',
clientSecret: '##MS365_CLIENT_SECRET##',
...(updated.credentials || {}),
};
}

return updated;
}
7 changes: 4 additions & 3 deletions src/tools/auth0/handlers/emailProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { EmailProviderCreate } from 'auth0';
import { isEmpty } from 'lodash';
import DefaultHandler, { order } from './default';
import { Asset, Assets } from '../../../types';
import log from '../../../logger';

export const schema = { type: 'object' };

Expand Down Expand Up @@ -41,10 +42,10 @@ export default class EmailProviderHandler extends DefaultHandler {

const existing = await this.getType();

// HTTP DELETE on emails/provider is not public, so not part of our vNext SDK.
// HTTP DELETE on emails/provider is not supported, as this is not part of our vNext SDK.
if (Object.keys(emailProvider).length === 0) {
if (this.config('AUTH0_ALLOW_DELETE') === true) {
// await this.client.emails.delete();
// await this.client.emails.delete(); is not supported
existing.enabled = false;
if (isEmpty(existing.credentials)) {
delete existing.credentials;
Expand All @@ -59,7 +60,7 @@ export default class EmailProviderHandler extends DefaultHandler {
if (existing.name) {
if (existing.name !== emailProvider.name) {
// Delete the current provider as it's different
// await this.client.emailProvider.delete();
// await this.client.emailProvider.delete(); is not supported
existing.enabled = false;
}
}
Expand Down

0 comments on commit 42630e7

Please sign in to comment.