Skip to content

Commit

Permalink
feat(core): Add support for oauth based service accounts with UM SMTP (
Browse files Browse the repository at this point in the history
…#7311)

This PR adds support for using OAuth based service accounts for the User
Management SMTP connection.

Tested using a Google Service Account.
  • Loading branch information
Joffcom committed Oct 20, 2023
1 parent 91dfc4d commit 647372b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
14 changes: 14 additions & 0 deletions packages/cli/src/UserManagement/email/NodeMailer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,20 @@ export class NodeMailer {
};
}

if (
config.getEnv('userManagement.emails.smtp.auth.serviceClient') &&
config.getEnv('userManagement.emails.smtp.auth.privateKey')
) {
transportConfig.auth = {
type: 'OAuth2',
user: config.getEnv('userManagement.emails.smtp.auth.user'),
serviceClient: config.getEnv('userManagement.emails.smtp.auth.serviceClient'),
privateKey: config
.getEnv('userManagement.emails.smtp.auth.privateKey')
.replace(/\\n/g, '\n'),
};
}

this.transport = createTransport(transportConfig);
}

Expand Down
12 changes: 12 additions & 0 deletions packages/cli/src/config/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,18 @@ export const schema = {
default: '',
env: 'N8N_SMTP_PASS',
},
serviceClient: {
doc: 'SMTP OAuth Service Client',
format: String,
default: '',
env: 'N8N_SMTP_OAUTH_SERVICE_CLIENT',
},
privateKey: {
doc: 'SMTP OAuth Private Key',
format: String,
default: '',
env: 'N8N_SMTP_OAUTH_PRIVATE_KEY',
},
},
sender: {
doc: 'How to display sender name',
Expand Down

0 comments on commit 647372b

Please sign in to comment.