Description
Describe the bug
- Create a new realm with SMTP credentials defined.
- Try to send an email, it works.
- Then, create a new custom authentication flow and bind it with the resetCredentialsFlow, for example.
- Deploy it with pulumi up.
- If you try now to send an email it will fail because the SMTP credentials were overwritten.
Version
26.2.2, 5.2.0 terraform-provider-keycloak
Expected behavior
No response
Actual behavior
No response
How to Reproduce?
Create a new realm via terraform with the smtp_server attribute defined:
resource "keycloak_realm" "test" {
realm = "test"
enabled = true
display_name = "Test"
smtp_server {
host = "host.com"
from = "[email protected]"
ssl = true
from_display_name = "test"
auth {
username = "username"
password = "password"
}
}
}
Deploy it, and test the email sending, it should work.
Then, create a new custom authentication flow and bind it with the resetCredentialsFlow, for example:
resource "keycloak_authentication_flow" "test_reset_flow" {
alias = "resetCredentialsCopy"
realm_id = keycloak_realm.test.id
description = "browser based authentication"
}
resource "keycloak_authentication_bindings" "test_flow_binding" {
realm_id = keycloak_realm.test.id
reset_credentials_flow = keycloak_authentication_flow.test_reset_flow.alias
}
If you try now to send an email it will fail because the SMTP credentials were overwritten.
Anything else?
This only started to happen after we are upgraded to keycloak version 26.2.0.
On that version they added Token based authentication for SMTP https://www.keycloak.org/docs/latest/release_notes/index.html#token-based-authentication-for-smtp-xoauth2
Maybe it's related with this starting now to fail.
I noticed also another thing on the Admin events on the troublesome realm, on the update realm event the realm representation init has different attributes, on the smtpServer attribute, depending if it was updated via the admin console or via terraform, here is an example of the smtpServer attribute on those realm representations:
- Update via terraform:
"smtpServer": {
"auth": "true",
"host": "host.com",
"from": "[email protected]",
"fromDisplayName": "test",
"ssl": "true",
"user": "username",
"password": "**********"
},
- Update via admin console:
"smtpServer": {
"password": "**********",
"auth": "true",
"host": "host.com",
"from": "[email protected]",
"fromDisplayName": "test",
"ssl": "true",
"user": "username",
"replyTo": "",
"replyToDisplayName": "",
"envelopeFrom": "",
"starttls": "false",
"authType": "basic",
"debug": "false"
},