feat(core): Add support for oauth based service accounts with UM SMTP (#7311)

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

Tested using a Google Service Account.
This commit is contained in:
Jon 2023-10-20 11:36:40 +01:00 committed by GitHub
parent 91dfc4d513
commit 647372be27
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 0 deletions

View file

@ -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);
}

View file

@ -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',