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

Allow configuring SAML Signuture Key Name #529

Closed
wants to merge 1 commit into from
Closed
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 keycloak/saml_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type SamlClientAttributes struct {
ForceNameIdFormat *string `json:"saml_force_name_id_format"`
// attributes above are actually booleans, but the Keycloak API expects strings
SignatureAlgorithm string `json:"saml.signature.algorithm"`
SignatureKeyName string `json:"saml.server.signature.keyinfo.xmlSigKeyInfoKeyNameTransformer"`
NameIdFormat string `json:"saml_name_id_format"`
SigningCertificate *string `json:"saml.signing.certificate,omitempty"`
SigningPrivateKey *string `json:"saml.signing.private.key"`
Expand Down
7 changes: 7 additions & 0 deletions provider/resource_keycloak_saml_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
var (
keycloakSamlClientNameIdFormats = []string{"username", "email", "transient", "persistent"}
keycloakSamlClientSignatureAlgorithms = []string{"RSA_SHA1", "RSA_SHA256", "RSA_SHA512", "DSA_SHA1"}
keycloakSamlClientSignatureKeyName = []string{"NONE", "KEY_ID", "CERT_SUBJECT"}
)

func resourceKeycloakSamlClient() *schema.Resource {
Expand Down Expand Up @@ -93,6 +94,12 @@ func resourceKeycloakSamlClient() *schema.Resource {
Optional: true,
ValidateFunc: validation.StringInSlice(keycloakSamlClientSignatureAlgorithms, false),
},
"signature_key_name": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since we never call a data.Get or data.Set for this schema attribute, it is essentially ignored. take a look at the mapToSamlClientFromData and mapToDataFromSamlClient functions to see where these should be added.

Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validation.StringInSlice(keycloakSamlClientSignatureKeyName, false),
},
"name_id_format": {
Type: schema.TypeString,
Optional: true,
Expand Down
4 changes: 4 additions & 0 deletions provider/resource_keycloak_saml_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ func TestAccKeycloakSamlClient_updateInPlace(t *testing.T) {
ForcePostBinding: randomBoolAsStringPointer(),
ForceNameIdFormat: randomBoolAsStringPointer(),
SignatureAlgorithm: randomStringInSlice(keycloakSamlClientSignatureAlgorithms),
SignatureKeyName: randomStringInSlice(keycloakSamlClientSignatureKeyName),
NameIdFormat: randomStringInSlice(keycloakSamlClientNameIdFormats),
EncryptionCertificate: &encryptionCertificateBefore,
SigningCertificate: &signingCertificateBefore,
Expand Down Expand Up @@ -200,6 +201,7 @@ func TestAccKeycloakSamlClient_updateInPlace(t *testing.T) {
ForcePostBinding: randomBoolAsStringPointer(),
ForceNameIdFormat: randomBoolAsStringPointer(),
SignatureAlgorithm: randomStringInSlice(keycloakSamlClientSignatureAlgorithms),
SignatureKeyName: randomStringInSlice(keycloakSamlClientSignatureKeyName),
NameIdFormat: randomStringInSlice(keycloakSamlClientNameIdFormats),
EncryptionCertificate: &encryptionCertificateAfter,
SigningCertificate: &signingCertificateAfter,
Expand Down Expand Up @@ -613,6 +615,7 @@ resource "keycloak_saml_client" "saml_client" {

front_channel_logout = %t
signature_algorithm = "%s"
signature_key_name = "%s"
name_id_format = "%s"
root_url = "%s"
valid_redirect_uris = %s
Expand Down Expand Up @@ -645,6 +648,7 @@ resource "keycloak_saml_client" "saml_client" {
*client.Attributes.ForceNameIdFormat,
client.FrontChannelLogout,
client.Attributes.SignatureAlgorithm,
client.Attributes.SignatureKeyName,
client.Attributes.NameIdFormat,
client.RootUrl,
arrayOfStringsForTerraformResource(client.ValidRedirectUris),
Expand Down