Skip to content

Commit

Permalink
1073 add organization setting to realm
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastian Schuster <[email protected]>
  • Loading branch information
sschu committed Jan 15, 2025
1 parent e8ccbc6 commit 722c31d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/resources/realm.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
1 change: 1 addition & 0 deletions keycloak/realm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
4 changes: 4 additions & 0 deletions provider/data_source_keycloak_realm.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ func dataSourceKeycloakRealm() *schema.Resource {
Type: schema.TypeBool,
Computed: true,
},
"organizations": {
Type: schema.TypeBool,
Computed: true,
},

// Login Config

Expand Down
7 changes: 7 additions & 0 deletions provider/resource_keycloak_realm.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,11 @@ func resourceKeycloakRealm() *schema.Resource {
Optional: true,
Default: false,
},
"organizations": {
Type: schema.TypeBool,
Optional: true,
Default: false,
},

// Login Config
"registration_allowed": {
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 722c31d

Please sign in to comment.