Skip to content

Commit 5fcefb5

Browse files
1073 add organization setting to realm (#1076)
* 1073 add organization setting to realm Signed-off-by: Sebastian Schuster <[email protected]> * Apply suggestions from code review Co-authored-by: Thomas Darimont <[email protected]> Signed-off-by: Sebastian Schuster <[email protected]> * Format fix Signed-off-by: Sebastian Schuster <[email protected]> --------- Signed-off-by: Sebastian Schuster <[email protected]> Signed-off-by: Sebastian Schuster <[email protected]> Co-authored-by: Thomas Darimont <[email protected]>
1 parent d830181 commit 5fcefb5

File tree

4 files changed

+25
-12
lines changed

4 files changed

+25
-12
lines changed

docs/resources/realm.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ resource "keycloak_realm" "realm" {
8383
- `display_name` - (Optional) The display name for the realm that is shown when logging in to the admin console.
8484
- `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.
8585
- `user_managed_access` - (Optional) When `true`, users are allowed to manage their own resources. Defaults to `false`.
86+
- `organizations_enabled` - (Optional) When `true`, organization support is enabled. Defaults to `false`.
8687
- `attributes` - (Optional) A map of custom attributes to add to the realm.
8788
- `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.
8889

keycloak/realm.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,13 @@ type Keys struct {
2323
}
2424

2525
type Realm struct {
26-
Id string `json:"id,omitempty"`
27-
Realm string `json:"realm"`
28-
Enabled bool `json:"enabled"`
29-
DisplayName string `json:"displayName"`
30-
DisplayNameHtml string `json:"displayNameHtml"`
31-
UserManagedAccess bool `json:"userManagedAccessAllowed"`
26+
Id string `json:"id,omitempty"`
27+
Realm string `json:"realm"`
28+
Enabled bool `json:"enabled"`
29+
DisplayName string `json:"displayName"`
30+
DisplayNameHtml string `json:"displayNameHtml"`
31+
UserManagedAccess bool `json:"userManagedAccessAllowed"`
32+
OrganizationsEnabled bool `json:"organizationsEnabled,omitempty"`
3233

3334
// Login Config
3435
RegistrationAllowed bool `json:"registrationAllowed"`

provider/data_source_keycloak_realm.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@ func dataSourceKeycloakRealm() *schema.Resource {
116116
Type: schema.TypeBool,
117117
Computed: true,
118118
},
119+
"organizations_enabled": {
120+
Type: schema.TypeBool,
121+
Computed: true,
122+
},
119123

120124
// Login Config
121125

provider/resource_keycloak_realm.go

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,11 @@ func resourceKeycloakRealm() *schema.Resource {
179179
Optional: true,
180180
Default: false,
181181
},
182+
"organizations_enabled": {
183+
Type: schema.TypeBool,
184+
Optional: true,
185+
Default: false,
186+
},
182187

183188
// Login Config
184189
"registration_allowed": {
@@ -739,12 +744,13 @@ func getRealmFromData(data *schema.ResourceData) (*keycloak.Realm, error) {
739744
}
740745

741746
realm := &keycloak.Realm{
742-
Id: realmId.(string),
743-
Realm: data.Get("realm").(string),
744-
Enabled: data.Get("enabled").(bool),
745-
DisplayName: data.Get("display_name").(string),
746-
DisplayNameHtml: data.Get("display_name_html").(string),
747-
UserManagedAccess: data.Get("user_managed_access").(bool),
747+
Id: realmId.(string),
748+
Realm: data.Get("realm").(string),
749+
Enabled: data.Get("enabled").(bool),
750+
DisplayName: data.Get("display_name").(string),
751+
DisplayNameHtml: data.Get("display_name_html").(string),
752+
UserManagedAccess: data.Get("user_managed_access").(bool),
753+
OrganizationsEnabled: data.Get("organizations_enabled").(bool),
748754

749755
// Login Config
750756
RegistrationAllowed: data.Get("registration_allowed").(bool),
@@ -1179,6 +1185,7 @@ func setRealmData(data *schema.ResourceData, realm *keycloak.Realm) {
11791185
data.Set("display_name", realm.DisplayName)
11801186
data.Set("display_name_html", realm.DisplayNameHtml)
11811187
data.Set("user_managed_access", realm.UserManagedAccess)
1188+
data.Set("organizations_enabled", realm.OrganizationsEnabled)
11821189

11831190
// Login Config
11841191
data.Set("registration_allowed", realm.RegistrationAllowed)

0 commit comments

Comments
 (0)