Skip to content
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

DXCDT-741 Add support for configuring email provider #1120

Merged
merged 2 commits into from
Jan 17, 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
1 change: 1 addition & 0 deletions docs/auth0_email.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ You can configure a test SMTP email server in your development or test environme

## Commands

- [auth0 email provider](auth0_email_provider.md) - Manage custom email provider
- [auth0 email templates](auth0_email_templates.md) - Manage custom email templates

16 changes: 16 additions & 0 deletions docs/auth0_email_provider.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
layout: default
has_toc: false
has_children: true
---
# auth0 email provider

Manage custom email provider for the tenant.

## Commands

- [auth0 email provider create](auth0_email_provider_create.md) - Create the email provider
- [auth0 email provider delete](auth0_email_provider_delete.md) - Delete the email provider
- [auth0 email provider show](auth0_email_provider_show.md) - Show the email provider
- [auth0 email provider update](auth0_email_provider_update.md) - Update the email provider

68 changes: 68 additions & 0 deletions docs/auth0_email_provider_create.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
---
layout: default
parent: auth0 email provider
has_toc: false
---
# auth0 email provider create

Create the email provider.

To create interactively, use `auth0 email provider create` with no arguments.

To create non-interactively, supply the provider name and other information through the flags.

## Usage
```
auth0 email provider create [flags]
```

## Examples

```
auth0 email provider create
auth0 email provider create --json
auth0 email provider create --provider mandrill --enabled=true --credentials='{ "api_key":"TheAPIKey" }' --settings='{ "message": { "view_control_link": true } }'
auth0 email provider create --provider mandrill --default-from-address='admin@example.com' --credentials='{ "api_key":"TheAPIKey" }' --settings='{ "message": { "view_control_link": true } }'
auth0 email provider create --provider ses --credentials='{ "accessKeyId":"TheAccessKeyId", "secretAccessKey":"TheSecretAccessKey", "region":"eu" }' --settings='{ "message": { "configuration_set_name": "TheConfigurationSetName" } }'
auth0 email provider create --provider sendgrid --credentials='{ "api_key":"TheAPIKey" }'
auth0 email provider create --provider sparkpost --credentials='{ "api_key":"TheAPIKey" }'
auth0 email provider create --provider sparkpost --credentials='{ "api_key":"TheAPIKey", "region":"eu" }'
auth0 email provider create --provider mailgun --credentials='{ "api_key":"TheAPIKey", "domain": "example.com"}'
auth0 email provider create --provider mailgun --credentials='{ "api_key":"TheAPIKey", "domain": "example.com", "region":"eu" }'
auth0 email provider create --provider smtp --credentials='{ "smtp_host":"smtp.example.com", "smtp_port":25, "smtp_user":"smtp", "smtp_pass":"TheSMTPPassword" }'
auth0 email provider create --provider azure_cs --credentials='{ "connection_string":"TheConnectionString" }'
auth0 email provider create --provider ms365 --credentials='{ "tenantId":"TheTenantId", "clientId":"TheClientID", "clientSecret":"TheClientSecret" }'
auth0 email provider create --provider custom --enabled=true --default-from-address="admin@example.com"
```


## Flags

```
-c, --credentials string Credentials for the email provider, formatted as JSON.
-f, --default-from-address string Provider default FROM address if none is specified.
-e, --enabled Whether the provided is enabled (true) or disabled (false). (default true)
--json Output in json format.
-p, --provider string Provider name. Can be 'mandrill', 'ses', 'sendgrid', 'sparkpost', 'mailgun', 'smtp', 'azure_cs', 'ms365', or 'custom'
-s, --settings string Settings for the email provider. formatted as JSON.
```


## Inherited Flags

```
--debug Enable debug mode.
--no-color Disable colors.
--no-input Disable interactivity.
--tenant string Specific tenant to use.
```


## Related Commands

- [auth0 email provider create](auth0_email_provider_create.md) - Create the email provider
- [auth0 email provider delete](auth0_email_provider_delete.md) - Delete the email provider
- [auth0 email provider show](auth0_email_provider_show.md) - Show the email provider
- [auth0 email provider update](auth0_email_provider_update.md) - Update the email provider


53 changes: 53 additions & 0 deletions docs/auth0_email_provider_delete.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
layout: default
parent: auth0 email provider
has_toc: false
---
# auth0 email provider delete

Delete the email provider.

To delete interactively, use `auth0 email provider delete` with no arguments.

To delete non-interactively, supply the the `--force` flag to skip confirmation.

## Usage
```
auth0 email provider delete [flags]
```

## Examples

```
auth0 provider delete
auth0 email provider rm
auth0 email provider delete --force
auth0 email provider rm --force
```


## Flags

```
--force Skip confirmation.
```


## Inherited Flags

```
--debug Enable debug mode.
--no-color Disable colors.
--no-input Disable interactivity.
--tenant string Specific tenant to use.
```


## Related Commands

- [auth0 email provider create](auth0_email_provider_create.md) - Create the email provider
- [auth0 email provider delete](auth0_email_provider_delete.md) - Delete the email provider
- [auth0 email provider show](auth0_email_provider_show.md) - Show the email provider
- [auth0 email provider update](auth0_email_provider_update.md) - Update the email provider


47 changes: 47 additions & 0 deletions docs/auth0_email_provider_show.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
layout: default
parent: auth0 email provider
has_toc: false
---
# auth0 email provider show

Display information about the email provider.

## Usage
```
auth0 email provider show [flags]
```

## Examples

```
auth0 email provider show
auth0 email provider show --json
```


## Flags

```
--json Output in json format.
```


## Inherited Flags

```
--debug Enable debug mode.
--no-color Disable colors.
--no-input Disable interactivity.
--tenant string Specific tenant to use.
```


## Related Commands

- [auth0 email provider create](auth0_email_provider_create.md) - Create the email provider
- [auth0 email provider delete](auth0_email_provider_delete.md) - Delete the email provider
- [auth0 email provider show](auth0_email_provider_show.md) - Show the email provider
- [auth0 email provider update](auth0_email_provider_update.md) - Update the email provider


72 changes: 72 additions & 0 deletions docs/auth0_email_provider_update.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
---
layout: default
parent: auth0 email provider
has_toc: false
---
# auth0 email provider update

Update the email provider.

To update interactively, use `auth0 email provider update` with no arguments.

To update non-interactively, supply the provider name and other information through the flags.

## Usage
```
auth0 email provider update [flags]
```

## Examples

```
auth0 email provider update
auth0 email provider update --json
auth0 email provider update --enabled=false
auth0 email provider update --credentials='{ "api_key":"NewAPIKey" }'
auth0 email provider update --settings='{ "message": { "view_control_link": true } }'
auth0 email provider update --default-from-address="admin@example.com"
auth0 email provider update --provider mandrill --enabled=true --credentials='{ "api_key":"TheAPIKey" }' --settings='{ "message": { "view_control_link": true } }'
auth0 email provider update --provider mandrill --default-from-address='admin@example.com' --credentials='{ "api_key":"TheAPIKey" }' --settings='{ "message": { "view_control_link": true } }'
auth0 email provider update --provider ses --credentials='{ "accessKeyId":"TheAccessKeyId", "secretAccessKey":"TheSecretAccessKey", "region":"eu" }' --settings='{ "message": { "configuration_set_name": "TheConfigurationSetName" } }'
auth0 email provider update --provider sendgrid --credentials='{ "api_key":"TheAPIKey" }'
auth0 email provider update --provider sparkpost --credentials='{ "api_key":"TheAPIKey" }'
auth0 email provider update --provider sparkpost --credentials='{ "api_key":"TheAPIKey", "region":"eu" }'
auth0 email provider update --provider mailgun --credentials='{ "api_key":"TheAPIKey", "domain": "example.com"}'
auth0 email provider update --provider mailgun --credentials='{ "api_key":"TheAPIKey", "domain": "example.com", "region":"eu" }'
auth0 email provider update --provider smtp --credentials='{ "smtp_host":"smtp.example.com", "smtp_port":25, "smtp_user":"smtp", "smtp_pass":"TheSMTPPassword" }'
auth0 email provider update --provider azure_cs --credentials='{ "connection_string":"TheConnectionString" }'
auth0 email provider update --provider ms365 --credentials='{ "tenantId":"TheTenantId", "clientId":"TheClientID", "clientSecret":"TheClientSecret" }'
auth0 email provider update --provider custom --enabled=true --default-from-address="admin@example.com"
```


## Flags

```
-c, --credentials string Credentials for the email provider, formatted as JSON.
-f, --default-from-address string Provider default FROM address if none is specified.
-e, --enabled Whether the provided is enabled (true) or disabled (false). (default true)
--json Output in json format.
-p, --provider string Provider name. Can be 'mandrill', 'ses', 'sendgrid', 'sparkpost', 'mailgun', 'smtp', 'azure_cs', 'ms365', or 'custom'
-s, --settings string Settings for the email provider. formatted as JSON.
```


## Inherited Flags

```
--debug Enable debug mode.
--no-color Disable colors.
--no-input Disable interactivity.
--tenant string Specific tenant to use.
```


## Related Commands

- [auth0 email provider create](auth0_email_provider_create.md) - Create the email provider
- [auth0 email provider delete](auth0_email_provider_delete.md) - Delete the email provider
- [auth0 email provider show](auth0_email_provider_show.md) - Show the email provider
- [auth0 email provider update](auth0_email_provider_update.md) - Update the email provider


13 changes: 13 additions & 0 deletions internal/auth0/email_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,20 @@ import (
)

type EmailProviderAPI interface {
// Create email provider.
// See: https://auth0.com/docs/api/management/v2#!/Emails/post_provider
Create(ctx context.Context, ep *management.EmailProvider, opts ...management.RequestOption) error

// Update email provider.
// See: https://auth0.com/docs/api/management/v2#!/Emails/patch_provider
Update(ctx context.Context, ep *management.EmailProvider, opts ...management.RequestOption) (err error)

// Read email provider details.
// See: https://auth0.com/docs/api/management/v2#!/Emails/get_provider
Read(ctx context.Context, opts ...management.RequestOption) (ep *management.EmailProvider, err error)

// Delete the email provider.
//
// See: https://auth0.com/docs/api/management/v2#!/Emails/delete_provider
Delete(ctx context.Context, opts ...management.RequestOption) (err error)
}
57 changes: 57 additions & 0 deletions internal/auth0/mock/email_provider_mock.go

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

1 change: 1 addition & 0 deletions internal/cli/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ var (
"post-user-registration": actionTemplatePostUserRegistration,
"post-change-password": actionTemplatePostChangePassword,
"send-phone-message": actionTemplateSendPhoneMessage,
"custom-email-provider": actionTemplateCustomEmailProvider,
}
)

Expand Down
3 changes: 3 additions & 0 deletions internal/cli/actions_embed.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ var (
//go:embed data/action-template-send-phone-message.js
actionTemplateSendPhoneMessage string

//go:embed data/action-template-custom-email-provider.js
actionTemplateCustomEmailProvider string

//go:embed data/action-template-empty.js
actionTemplateEmpty string
)
9 changes: 9 additions & 0 deletions internal/cli/data/action-template-custom-email-provider.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* Handler to be executed while sending an email notification
* @param {Event} event - Details about the user and the context in which they are logging in.
* @param {CustomEmailProviderAPI} api - Methods and utilities to help change the behavior of sending a email notification.
*/
exports.onExecuteCustomEmailProvider = async (event, api) => {
// Code goes here
return;
};
1 change: 1 addition & 0 deletions internal/cli/email.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ func emailCmd(cli *cli) *cobra.Command {
}

cmd.AddCommand(emailTemplateCmd(cli))
cmd.AddCommand(emailProviderCmd(cli))

return cmd
}
Loading
Loading