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

OA-42: Encode request parameter values in the logout url #30

Merged
merged 1 commit into from
Jan 29, 2025

Conversation

wluyima
Copy link
Member

@wluyima wluyima commented Jan 28, 2025

Copy link
Member

@corneliouzbett corneliouzbett left a comment

Choose a reason for hiding this comment

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

This LGTM! Let's add one more test to handle edge cases like empty query parameters or null parameters.

@wluyima
Copy link
Member Author

wluyima commented Jan 29, 2025

Empty query parameter is effectively a blank parameter value which is the same as any other parameter value in my opinion.

}

@Test
public void getPostLogoutRedirectUrl_shouldEncodeTheUrlIfDisabled() throws Exception {
Copy link
Member Author

Choose a reason for hiding this comment

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

Ooops! This should be shouldNotEncodeUrlIfDisabled

OA-42: Added property to disable encoding of post logout URL

OA-42: Added property to disable encoding of post logout URL
Comment on lines +78 to +83
if (params != null) {
for (Map.Entry<String, List<String>> entry : params.entrySet()) {
final String encodedKey = URLEncoder.encode(entry.getKey());
entry.getValue().forEach(v -> urlBuilderEncoded.queryParam(encodedKey, URLEncoder.encode(v)));
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Empty query parameter is effectively a blank parameter value which is the same as any other parameter value in my opinion.

I get your point, I was suggesting to capture (or unit test) the above functionality. What is the expected outcome if params == null, can we capture that in tests

Copy link
Member Author

@wluyima wluyima Jan 29, 2025

Choose a reason for hiding this comment

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

I get what you are saying, but is there an IDP that accepts a parameterless logout URL anyways? I intentionally omitted that test, in fact, for this reason I wanted to remove that if clause instead, params can never be null or empty otherwise that would be an invalid URL since the client_id or the id_token_hint parameter is required but this could be Keycloak's implementation to require one of them, may be it is not the case for other implementations, so may be it make senses avoid a potential NPE in case of other IDPs that might might accept a parameterless logout URL.

Copy link
Member

Choose a reason for hiding this comment

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

➕ it's a utility method, someone might want to use it to encode a URL that's not specific to Keycloak's implementation.

@rbuisson rbuisson merged commit a83a630 into openmrs:master Jan 29, 2025
1 check passed
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 this pull request may close these issues.

3 participants