-
Notifications
You must be signed in to change notification settings - Fork 376
Ensure security defenses settings are set on setRealmData realm (#1257) #1279
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Ensure security defenses settings are set on setRealmData realm (#1257) #1279
Conversation
…loak#1257) This ensures that the securityDefensesSettings propagated to the terraform state. Avoid repeated call to setRealmData(..) from resourceKeycloakRealmCreate. Mark resource_keycloak_realm `security_defenses` property as computed as it is populated with defaults after realm creation. Fixes keycloak#1257 Signed-off-by: Thomas Darimont <[email protected]>
e45bb10 to
91a5cc8
Compare
thomasdarimont
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some explanations.
| DefaultOptionalClientScopes []string `json:"defaultOptionalClientScopes,omitempty"` | ||
|
|
||
| BrowserSecurityHeaders BrowserSecurityHeaders `json:"browserSecurityHeaders"` | ||
| BrowserSecurityHeaders *BrowserSecurityHeaders `json:"browserSecurityHeaders,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
omitempty allows us to leverage the BrowserSecurityHeader defaults from Keycloak.
| if realm.BruteForceProtected { | ||
| securityDefensesSettings["brute_force_detection"] = []interface{}{getBruteForceDetectionSettings(realm)} | ||
| } | ||
| data.Set("security_defenses", []interface{}{securityDefensesSettings}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This populates the tfstate with the security defenses defaults configured generated by Keycloak.
| } | ||
|
|
||
| setRealmData(data, realm, keycloakVersion) | ||
| data.SetId(realm.Realm) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The call to setRealmData(...) was not necessary as it is already done by resourceKeycloakRealmRead(..), however we do need to set the realm ID via SetId before.
thomasdarimont
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some explanations.
…oak default securityDefensesHeaders configuration Signed-off-by: Thomas Darimont <[email protected]>
This ensures that the securityDefensesSettings propagated to the terraform state.
Previously we didn't set the security defenses settings configuration generated by Keycloak. As a consequence
terraform was not aware of the actual security defines configuration and attempted to perform a bigger update than necessary.
Fixes #1257