From 722c31d0bdf41d4f4b52236a115ccecbd051932b Mon Sep 17 00:00:00 2001 From: Sebastian Schuster Date: Wed, 15 Jan 2025 21:01:28 +0100 Subject: [PATCH] 1073 add organization setting to realm Signed-off-by: Sebastian Schuster --- docs/resources/realm.md | 1 + keycloak/realm.go | 1 + provider/data_source_keycloak_realm.go | 4 ++++ provider/resource_keycloak_realm.go | 7 +++++++ 4 files changed, 13 insertions(+) diff --git a/docs/resources/realm.md b/docs/resources/realm.md index 82dc30cd5..fee49eef2 100644 --- a/docs/resources/realm.md +++ b/docs/resources/realm.md @@ -83,6 +83,7 @@ resource "keycloak_realm" "realm" { - `display_name` - (Optional) The display name for the realm that is shown when logging in to the admin console. - `display_name_html` - (Optional) The display name for the realm that is rendered as HTML on the screen when logging in to the admin console. - `user_managed_access` - (Optional) When `true`, users are allowed to manage their own resources. Defaults to `false`. +- `organizations` - (Optional) When `true`, organization support is enabled. Defaults to `false`. - `attributes` - (Optional) A map of custom attributes to add to the realm. - `internal_id` - (Optional) When specified, this will be used as the realm's internal ID within Keycloak. When not specified, the realm's internal ID will be set to the realm's name. diff --git a/keycloak/realm.go b/keycloak/realm.go index 9196b6411..cc47c6586 100644 --- a/keycloak/realm.go +++ b/keycloak/realm.go @@ -29,6 +29,7 @@ type Realm struct { DisplayName string `json:"displayName"` DisplayNameHtml string `json:"displayNameHtml"` UserManagedAccess bool `json:"userManagedAccessAllowed"` + Organizations bool `json:"organizationsEnabled"` // Login Config RegistrationAllowed bool `json:"registrationAllowed"` diff --git a/provider/data_source_keycloak_realm.go b/provider/data_source_keycloak_realm.go index bab9d5eb9..7924a984d 100644 --- a/provider/data_source_keycloak_realm.go +++ b/provider/data_source_keycloak_realm.go @@ -116,6 +116,10 @@ func dataSourceKeycloakRealm() *schema.Resource { Type: schema.TypeBool, Computed: true, }, + "organizations": { + Type: schema.TypeBool, + Computed: true, + }, // Login Config diff --git a/provider/resource_keycloak_realm.go b/provider/resource_keycloak_realm.go index badeba995..1cf0c6341 100644 --- a/provider/resource_keycloak_realm.go +++ b/provider/resource_keycloak_realm.go @@ -179,6 +179,11 @@ func resourceKeycloakRealm() *schema.Resource { Optional: true, Default: false, }, + "organizations": { + Type: schema.TypeBool, + Optional: true, + Default: false, + }, // Login Config "registration_allowed": { @@ -745,6 +750,7 @@ func getRealmFromData(data *schema.ResourceData) (*keycloak.Realm, error) { DisplayName: data.Get("display_name").(string), DisplayNameHtml: data.Get("display_name_html").(string), UserManagedAccess: data.Get("user_managed_access").(bool), + Organizations: data.Get("organizations").(bool), // Login Config RegistrationAllowed: data.Get("registration_allowed").(bool), @@ -1179,6 +1185,7 @@ func setRealmData(data *schema.ResourceData, realm *keycloak.Realm) { data.Set("display_name", realm.DisplayName) data.Set("display_name_html", realm.DisplayNameHtml) data.Set("user_managed_access", realm.UserManagedAccess) + data.Set("organizations", realm.Organizations) // Login Config data.Set("registration_allowed", realm.RegistrationAllowed)