Skip to content
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

feat: Adding support for login theme on saml_client resource #590

Merged
merged 5 commits into from
Sep 13, 2021
Merged
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
1 change: 1 addition & 0 deletions docs/resources/saml_client.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ resource "keycloak_saml_client" "saml_client" {
- `name` - (Optional) The display name of this client in the GUI.
- `enabled` - (Optional) When false, this client will not be able to initiate a login or obtain access tokens. Defaults to `true`.
- `description` - (Optional) The description of this client in the GUI.
- `login_theme` - (Optional) The login theme of this client.
- `include_authn_statement` - (Optional) When `true`, an `AuthnStatement` will be included in the SAML response.
- `sign_documents` - (Optional) When `true`, the SAML document will be signed by Keycloak using the realm's private key.
- `sign_assertions` - (Optional) When `true`, the SAML assertions will be signed by Keycloak using the realm's private key, and embedded within the SAML XML Auth response.
Expand Down
1 change: 1 addition & 0 deletions keycloak/saml_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type SamlClientAttributes struct {
AssertionConsumerRedirectURL string `json:"saml_assertion_consumer_url_redirect"`
LogoutServicePostBindingURL string `json:"saml_single_logout_service_url_post"`
LogoutServiceRedirectBindingURL string `json:"saml_single_logout_service_url_redirect"`
LoginTheme string `json:"login_theme"`
}

type SamlAuthenticationFlowBindingOverrides struct {
Expand Down
4 changes: 4 additions & 0 deletions provider/data_source_keycloak_saml_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ func dataSourceKeycloakSamlClient() *schema.Resource {
},
},
},
"login_theme": {
Type: schema.TypeString,
Computed: true,
},
},
}
}
Expand Down
1 change: 1 addition & 0 deletions provider/data_source_keycloak_saml_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func TestAccKeycloakDataSourceSamlClient_basic(t *testing.T) {
resource.TestCheckResourceAttrPair(dataSourceName, "logout_service_post_binding_url", resourceName, "logout_service_post_binding_url"),
resource.TestCheckResourceAttrPair(dataSourceName, "logout_service_redirect_binding_url", resourceName, "logout_service_redirect_binding_url"),
resource.TestCheckResourceAttrPair(dataSourceName, "full_scope_allowed", resourceName, "full_scope_allowed"),
resource.TestCheckResourceAttrPair(dataSourceName, "login_theme", resourceName, "login_theme"),
),
},
},
Expand Down
6 changes: 6 additions & 0 deletions provider/resource_keycloak_saml_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ func resourceKeycloakSamlClient() *schema.Resource {
Type: schema.TypeString,
Optional: true,
},
"login_theme": {
Type: schema.TypeString,
Optional: true,
},
"master_saml_processing_url": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -234,6 +238,7 @@ func mapToSamlClientFromData(data *schema.ResourceData) *keycloak.SamlClient {
AssertionConsumerRedirectURL: data.Get("assertion_consumer_redirect_url").(string),
LogoutServicePostBindingURL: data.Get("logout_service_post_binding_url").(string),
LogoutServiceRedirectBindingURL: data.Get("logout_service_redirect_binding_url").(string),
LoginTheme: data.Get("login_theme").(string),
}

if encryptionCertificate, ok := data.GetOkExists("encryption_certificate"); ok {
Expand Down Expand Up @@ -420,6 +425,7 @@ func mapToDataFromSamlClient(data *schema.ResourceData, client *keycloak.SamlCli
data.Set("logout_service_post_binding_url", client.Attributes.LogoutServicePostBindingURL)
data.Set("logout_service_redirect_binding_url", client.Attributes.LogoutServiceRedirectBindingURL)
data.Set("full_scope_allowed", client.FullScopeAllowed)
data.Set("login_theme", client.Attributes.LoginTheme)

return nil
}
Expand Down
2 changes: 2 additions & 0 deletions provider/resource_keycloak_saml_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ func TestAccKeycloakSamlClient_updateInPlace(t *testing.T) {
AssertionConsumerRedirectURL: acctest.RandString(20),
LogoutServicePostBindingURL: acctest.RandString(20),
LogoutServiceRedirectBindingURL: acctest.RandString(20),
LoginTheme: "keycloak",
},
}

Expand Down Expand Up @@ -213,6 +214,7 @@ func TestAccKeycloakSamlClient_updateInPlace(t *testing.T) {
AssertionConsumerRedirectURL: acctest.RandString(20),
LogoutServicePostBindingURL: acctest.RandString(20),
LogoutServiceRedirectBindingURL: acctest.RandString(20),
LoginTheme: "keycloak",
},
}

Expand Down