Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/resources/realm.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ resource "keycloak_realm" "realm" {
from = "[email protected]"

auth {
auth_type = "basic"
username = "tom"
password = "password"
}
Expand Down Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions keycloak/realm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
9 changes: 9 additions & 0 deletions provider/resource_keycloak_realm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
},
},
},
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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}
}
Expand Down
Loading