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

DisplayOnConsentScreen broken for resource keycloak_openid_client_scope #492

Closed
vlaurin opened this issue Mar 4, 2021 · 1 comment · Fixed by #495
Closed

DisplayOnConsentScreen broken for resource keycloak_openid_client_scope #492

vlaurin opened this issue Mar 4, 2021 · 1 comment · Fixed by #495

Comments

@vlaurin
Copy link
Contributor

vlaurin commented Mar 4, 2021

Details

It seems like recent versions of the provider have broken the ability to turn off the "Display On Consent Screen" flag in Client Scopes.

Here's an example of a resource:

resource "keycloak_openid_client_scope" "test_client_scope" {
  realm_id = keycloak_realm.realm.id
  name = "resource-server/test-client-scope"
  description = "A test client scope"
  include_in_token_scope = false
}

And the resulting Client Scope in Keycloak:
image

The "Display On Consent Screen" flag is "On" when it should be "Off" as consent_screen_text is null.

Hypothesis

Digging around a bit, I believe this issue is a side effect of commit 4206fa1

As part of this commit, the attribute DisplayOnConsentScreen was changed from a string to a KeycloakBoolQuoted (Source).

However, when marshalled to JSON, KeycloakBoolQuoted is serialising false values as an empty string "". (Source)

As a result, the DisplayOnConsentScreen attribute which was previously sent to Keycloak as "false" is now being sent as "" (Source). And it seems Keycloak is interpreting that empty string as a positive instead of a negative.

I don't know if this is a wider issue of KeycloakBoolQuoted which should be patched globally; or a specificity of DisplayOnConsentScreen which means that the marshalling behaviour of KeycloakBoolQuoted is not suitable for it.

@vlaurin
Copy link
Contributor Author

vlaurin commented Mar 4, 2021

Actually, looking at the example above "Include In Token Scope" presents the same issue. It's explicitly set as false but results as a "On" in Keycloak.

vlaurin added a commit to vlaurin/terraform-provider-keycloak that referenced this issue Mar 11, 2021
Resolves mrparkers#492

`false` is currently marshalled to `""` (empty string). This is incorrect: `""` represents the default value for an attribute which hasn't been explicitly set.
`""` could be interpreted as either `true` or `false` depending on what the default value is in Keycloak for the attribute considered.
As a result, `""` and `"false"` are not equivalent and `"false"` must be used explicitly to accurately turn off Keycloak attributes and not rely on default Keycloak behaviours.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant