diff --git a/docs/resources/realm.md b/docs/resources/realm.md index ec1ed82f5..35d6a9969 100644 --- a/docs/resources/realm.md +++ b/docs/resources/realm.md @@ -33,6 +33,7 @@ resource "keycloak_realm" "realm" { from = "example@example.com" auth { + auth_type = "basic" username = "tom" password = "password" } @@ -161,6 +162,7 @@ This block supports the following arguments: - `auth` - (Optional) Enables authentication to the SMTP server. This block supports the following arguments: - `username` - (Required) The SMTP server username. - `password` - (Required) The SMTP server password. + - `auth_type` - (Optional) The authentication type. Only `basic` is supported by the provider which is for password based authentication. ### Internationalization diff --git a/keycloak/realm.go b/keycloak/realm.go index aa635187c..3d16eac72 100644 --- a/keycloak/realm.go +++ b/keycloak/realm.go @@ -170,6 +170,7 @@ type SmtpServer struct { Ssl types.KeycloakBoolQuoted `json:"ssl,omitempty"` User string `json:"user,omitempty"` Password string `json:"password,omitempty"` + AuthType string `json:"authType,omitempty"` } func (keycloakClient *KeycloakClient) NewRealm(ctx context.Context, realm *Realm) error { diff --git a/provider/resource_keycloak_realm.go b/provider/resource_keycloak_realm.go index 240782c61..8b39fe0af 100644 --- a/provider/resource_keycloak_realm.go +++ b/provider/resource_keycloak_realm.go @@ -303,6 +303,12 @@ func resourceKeycloakRealm() *schema.Resource { return smtpServerPassword == "**********" }, }, + "auth_type": { + Type: schema.TypeString, + Optional: true, + Default: "basic", + ValidateFunc: validation.StringInSlice([]string{"basic"}, false), // Only basic is supported by the provider for now + }, }, }, }, @@ -815,6 +821,8 @@ func getRealmFromData(data *schema.ResourceData, keycloakVersion *version.Versio smtpServer.Auth = true smtpServer.User = auth["username"].(string) smtpServer.Password = auth["password"].(string) + smtpServer.AuthType = auth["auth_type"].(string) + } else { smtpServer.Auth = false } @@ -1245,6 +1253,7 @@ func setRealmData(data *schema.ResourceData, realm *keycloak.Realm, keycloakVers auth["username"] = realm.SmtpServer.User auth["password"] = realm.SmtpServer.Password + auth["auth_type"] = realm.SmtpServer.AuthType smtpSettings["auth"] = []interface{}{auth} }