mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-27 22:48:52 +00:00
feat: added xoauth for smtp (#11239)
# Which Problems Are Solved - Some mail providers (e.g.: MS Exchange) have deprecated plain auth # How the Problems Are Solved Adds XOauth2 auth option to SMPT - SMTP config now can contain XOAuth2 auth config - Proto files are updated to have a oneof for configuration selection. Old fields for configuring plain auth are still available not to create a breaking change. These can be removed in the future. - Columns are added to the database to persist the config # Additional Changes none # Additional Context Replace this example with links to related issues, discussions, discord threads, or other sources with more context. Use the Closing #issue syntax for issues that are resolved with this PR. - Closes #8042 --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: Tim Möhlmann <[email protected]>
This commit is contained in:
co-authored by
Copilot
Tim Möhlmann
parent
96bbd6a65c
commit
3fc0ef2506
+104
-48
@@ -14,49 +14,57 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
prepareSMTPConfigStmt = `SELECT projections.smtp_configs5.creation_date,` +
|
||||
` projections.smtp_configs5.change_date,` +
|
||||
` projections.smtp_configs5.resource_owner,` +
|
||||
` projections.smtp_configs5.sequence,` +
|
||||
` projections.smtp_configs5.id,` +
|
||||
` projections.smtp_configs5.state,` +
|
||||
` projections.smtp_configs5.description,` +
|
||||
` projections.smtp_configs5_smtp.id,` +
|
||||
` projections.smtp_configs5_smtp.tls,` +
|
||||
` projections.smtp_configs5_smtp.sender_address,` +
|
||||
` projections.smtp_configs5_smtp.sender_name,` +
|
||||
` projections.smtp_configs5_smtp.reply_to_address,` +
|
||||
` projections.smtp_configs5_smtp.host,` +
|
||||
` projections.smtp_configs5_smtp.username,` +
|
||||
` projections.smtp_configs5_smtp.password,` +
|
||||
` projections.smtp_configs5_http.id,` +
|
||||
` projections.smtp_configs5_http.endpoint,` +
|
||||
` projections.smtp_configs5_http.signing_key` +
|
||||
` FROM projections.smtp_configs5` +
|
||||
` LEFT JOIN projections.smtp_configs5_smtp ON projections.smtp_configs5.id = projections.smtp_configs5_smtp.id AND projections.smtp_configs5.instance_id = projections.smtp_configs5_smtp.instance_id` +
|
||||
` LEFT JOIN projections.smtp_configs5_http ON projections.smtp_configs5.id = projections.smtp_configs5_http.id AND projections.smtp_configs5.instance_id = projections.smtp_configs5_http.instance_id`
|
||||
prepareSMTPConfigsStmt = `SELECT projections.smtp_configs5.creation_date,` +
|
||||
` projections.smtp_configs5.change_date,` +
|
||||
` projections.smtp_configs5.resource_owner,` +
|
||||
` projections.smtp_configs5.sequence,` +
|
||||
` projections.smtp_configs5.id,` +
|
||||
` projections.smtp_configs5.state,` +
|
||||
` projections.smtp_configs5.description,` +
|
||||
` projections.smtp_configs5_smtp.id,` +
|
||||
` projections.smtp_configs5_smtp.tls,` +
|
||||
` projections.smtp_configs5_smtp.sender_address,` +
|
||||
` projections.smtp_configs5_smtp.sender_name,` +
|
||||
` projections.smtp_configs5_smtp.reply_to_address,` +
|
||||
` projections.smtp_configs5_smtp.host,` +
|
||||
` projections.smtp_configs5_smtp.username,` +
|
||||
` projections.smtp_configs5_smtp.password,` +
|
||||
` projections.smtp_configs5_http.id,` +
|
||||
` projections.smtp_configs5_http.endpoint,` +
|
||||
` projections.smtp_configs5_http.signing_key,` +
|
||||
prepareSMTPConfigStmt = `SELECT projections.smtp_configs6.creation_date,` +
|
||||
` projections.smtp_configs6.change_date,` +
|
||||
` projections.smtp_configs6.resource_owner,` +
|
||||
` projections.smtp_configs6.sequence,` +
|
||||
` projections.smtp_configs6.id,` +
|
||||
` projections.smtp_configs6.state,` +
|
||||
` projections.smtp_configs6.description,` +
|
||||
` projections.smtp_configs6_smtp.id,` +
|
||||
` projections.smtp_configs6_smtp.tls,` +
|
||||
` projections.smtp_configs6_smtp.sender_address,` +
|
||||
` projections.smtp_configs6_smtp.sender_name,` +
|
||||
` projections.smtp_configs6_smtp.reply_to_address,` +
|
||||
` projections.smtp_configs6_smtp.host,` +
|
||||
` projections.smtp_configs6_smtp.username,` +
|
||||
` projections.smtp_configs6_smtp.password,` +
|
||||
` projections.smtp_configs6_smtp.xoauth2auth_client_credentials_client_id,` +
|
||||
` projections.smtp_configs6_smtp.xoauth2auth_client_credentials_client_secret,` +
|
||||
` projections.smtp_configs6_smtp.xoauth2auth_token_endpoint,` +
|
||||
` projections.smtp_configs6_smtp.xoauth2auth_scope,` +
|
||||
` projections.smtp_configs6_http.id,` +
|
||||
` projections.smtp_configs6_http.endpoint,` +
|
||||
` projections.smtp_configs6_http.signing_key` +
|
||||
` FROM projections.smtp_configs6` +
|
||||
` LEFT JOIN projections.smtp_configs6_smtp ON projections.smtp_configs6.id = projections.smtp_configs6_smtp.id AND projections.smtp_configs6.instance_id = projections.smtp_configs6_smtp.instance_id` +
|
||||
` LEFT JOIN projections.smtp_configs6_http ON projections.smtp_configs6.id = projections.smtp_configs6_http.id AND projections.smtp_configs6.instance_id = projections.smtp_configs6_http.instance_id`
|
||||
prepareSMTPConfigsStmt = `SELECT projections.smtp_configs6.creation_date,` +
|
||||
` projections.smtp_configs6.change_date,` +
|
||||
` projections.smtp_configs6.resource_owner,` +
|
||||
` projections.smtp_configs6.sequence,` +
|
||||
` projections.smtp_configs6.id,` +
|
||||
` projections.smtp_configs6.state,` +
|
||||
` projections.smtp_configs6.description,` +
|
||||
` projections.smtp_configs6_smtp.id,` +
|
||||
` projections.smtp_configs6_smtp.tls,` +
|
||||
` projections.smtp_configs6_smtp.sender_address,` +
|
||||
` projections.smtp_configs6_smtp.sender_name,` +
|
||||
` projections.smtp_configs6_smtp.reply_to_address,` +
|
||||
` projections.smtp_configs6_smtp.host,` +
|
||||
` projections.smtp_configs6_smtp.username,` +
|
||||
` projections.smtp_configs6_smtp.password,` +
|
||||
` projections.smtp_configs6_smtp.xoauth2auth_client_credentials_client_id,` +
|
||||
` projections.smtp_configs6_smtp.xoauth2auth_client_credentials_client_secret,` +
|
||||
` projections.smtp_configs6_smtp.xoauth2auth_token_endpoint,` +
|
||||
` projections.smtp_configs6_smtp.xoauth2auth_scope,` +
|
||||
` projections.smtp_configs6_http.id,` +
|
||||
` projections.smtp_configs6_http.endpoint,` +
|
||||
` projections.smtp_configs6_http.signing_key,` +
|
||||
` COUNT(*) OVER ()` +
|
||||
` FROM projections.smtp_configs5` +
|
||||
` LEFT JOIN projections.smtp_configs5_smtp ON projections.smtp_configs5.id = projections.smtp_configs5_smtp.id AND projections.smtp_configs5.instance_id = projections.smtp_configs5_smtp.instance_id` +
|
||||
` LEFT JOIN projections.smtp_configs5_http ON projections.smtp_configs5.id = projections.smtp_configs5_http.id AND projections.smtp_configs5.instance_id = projections.smtp_configs5_http.instance_id`
|
||||
` FROM projections.smtp_configs6` +
|
||||
` LEFT JOIN projections.smtp_configs6_smtp ON projections.smtp_configs6.id = projections.smtp_configs6_smtp.id AND projections.smtp_configs6.instance_id = projections.smtp_configs6_smtp.instance_id` +
|
||||
` LEFT JOIN projections.smtp_configs6_http ON projections.smtp_configs6.id = projections.smtp_configs6_http.id AND projections.smtp_configs6.instance_id = projections.smtp_configs6_http.instance_id`
|
||||
|
||||
prepareSMTPConfigCols = []string{
|
||||
"creation_date",
|
||||
@@ -74,6 +82,10 @@ var (
|
||||
"smtp_host",
|
||||
"smtp_user",
|
||||
"smtp_password",
|
||||
"xoauth2auth_client_credentials_client_id",
|
||||
"xoauth2auth_client_credentials_client_secret",
|
||||
"xoauth2auth_token_endpoint",
|
||||
"xoauth2auth_scope",
|
||||
"id",
|
||||
"endpoint",
|
||||
"signing_key",
|
||||
@@ -136,6 +148,10 @@ func Test_SMTPConfigPrepares(t *testing.T) {
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
},
|
||||
),
|
||||
},
|
||||
@@ -151,7 +167,9 @@ func Test_SMTPConfigPrepares(t *testing.T) {
|
||||
ReplyToAddress: "reply-to",
|
||||
Host: "host",
|
||||
User: "user",
|
||||
Password: &crypto.CryptoValue{},
|
||||
PlainAuth: &PlainAuth{
|
||||
Password: &crypto.CryptoValue{},
|
||||
},
|
||||
},
|
||||
ID: "2232323",
|
||||
State: domain.SMTPConfigStateActive,
|
||||
@@ -181,6 +199,10 @@ func Test_SMTPConfigPrepares(t *testing.T) {
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
"2232323",
|
||||
"endpoint",
|
||||
&crypto.CryptoValue{
|
||||
@@ -237,6 +259,10 @@ func Test_SMTPConfigPrepares(t *testing.T) {
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
},
|
||||
),
|
||||
},
|
||||
@@ -252,7 +278,9 @@ func Test_SMTPConfigPrepares(t *testing.T) {
|
||||
ReplyToAddress: "reply-to2",
|
||||
Host: "host2",
|
||||
User: "user2",
|
||||
Password: &crypto.CryptoValue{},
|
||||
PlainAuth: &PlainAuth{
|
||||
Password: &crypto.CryptoValue{},
|
||||
},
|
||||
},
|
||||
ID: "44442323",
|
||||
State: domain.SMTPConfigStateInactive,
|
||||
@@ -285,6 +313,10 @@ func Test_SMTPConfigPrepares(t *testing.T) {
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
},
|
||||
),
|
||||
},
|
||||
@@ -300,7 +332,9 @@ func Test_SMTPConfigPrepares(t *testing.T) {
|
||||
ReplyToAddress: "reply-to3",
|
||||
Host: "host3",
|
||||
User: "user3",
|
||||
Password: &crypto.CryptoValue{},
|
||||
PlainAuth: &PlainAuth{
|
||||
Password: &crypto.CryptoValue{},
|
||||
},
|
||||
},
|
||||
ID: "23234444",
|
||||
State: domain.SMTPConfigStateInactive,
|
||||
@@ -383,6 +417,10 @@ func Test_SMTPConfigsPrepares(t *testing.T) {
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
},
|
||||
},
|
||||
),
|
||||
@@ -404,7 +442,9 @@ func Test_SMTPConfigsPrepares(t *testing.T) {
|
||||
ReplyToAddress: "reply-to",
|
||||
Host: "host",
|
||||
User: "user",
|
||||
Password: &crypto.CryptoValue{},
|
||||
PlainAuth: &PlainAuth{
|
||||
Password: &crypto.CryptoValue{},
|
||||
},
|
||||
},
|
||||
ID: "2232323",
|
||||
State: domain.SMTPConfigStateActive,
|
||||
@@ -437,6 +477,10 @@ func Test_SMTPConfigsPrepares(t *testing.T) {
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
"2232323",
|
||||
"endpoint",
|
||||
&crypto.CryptoValue{
|
||||
@@ -465,6 +509,10 @@ func Test_SMTPConfigsPrepares(t *testing.T) {
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
},
|
||||
{
|
||||
testNow,
|
||||
@@ -485,6 +533,10 @@ func Test_SMTPConfigsPrepares(t *testing.T) {
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
},
|
||||
},
|
||||
),
|
||||
@@ -524,7 +576,9 @@ func Test_SMTPConfigsPrepares(t *testing.T) {
|
||||
ReplyToAddress: "reply-to2",
|
||||
Host: "host2",
|
||||
User: "user2",
|
||||
Password: &crypto.CryptoValue{},
|
||||
PlainAuth: &PlainAuth{
|
||||
Password: &crypto.CryptoValue{},
|
||||
},
|
||||
},
|
||||
ID: "44442323",
|
||||
State: domain.SMTPConfigStateInactive,
|
||||
@@ -542,7 +596,9 @@ func Test_SMTPConfigsPrepares(t *testing.T) {
|
||||
ReplyToAddress: "reply-to3",
|
||||
Host: "host3",
|
||||
User: "user3",
|
||||
Password: &crypto.CryptoValue{},
|
||||
PlainAuth: &PlainAuth{
|
||||
Password: &crypto.CryptoValue{},
|
||||
},
|
||||
},
|
||||
ID: "23234444",
|
||||
State: domain.SMTPConfigStateInactive,
|
||||
|
||||
Reference in New Issue
Block a user