feat: propagate custom user attributes over SCIM#165
feat: propagate custom user attributes over SCIM#165thib-d wants to merge 1 commit intomitodl:mainfrom
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the SCIM user provisioning functionality by enabling the propagation of custom user attributes defined in Keycloak. Previously, only standard attributes were synchronized. With this change, any additional, single-valued string attributes configured in Keycloak will now be sent to the SCIM server during user creation and updates, including support for PATCH operations. This provides greater flexibility and extensibility for integrating Keycloak with SCIM-compliant identity providers that require custom user data. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces the propagation of custom user attributes over SCIM, a valuable feature enhancement. The changes primarily affect UserAdapter.java to handle the extraction and transmission of these attributes, along with documentation updates in README.md. The implementation is mostly sound, but I have identified a couple of areas for improvement regarding code quality, encapsulation, and readability. My review includes suggestions to make the code more robust and maintainable.
| } | ||
|
|
||
| public Map<String, String> getCustomAttributes() { | ||
| return customAttributes; |
There was a problem hiding this comment.
The getCustomAttributes method returns a direct reference to the internal customAttributes map. This allows external code to modify the adapter's internal state, which can lead to unexpected behavior. It's better to return an unmodifiable view of the map to maintain encapsulation and prevent accidental modifications.
| return customAttributes; | |
| return java.util.Collections.unmodifiableMap(customAttributes); |
| String value = values.stream() | ||
| .filter(StringUtils::isNotBlank) | ||
| .findFirst() | ||
| .orElse(values.get(0)); | ||
| if (StringUtils.isNotBlank(value)) { | ||
| attributes.put(attributeName, value); | ||
| } |
There was a problem hiding this comment.
The logic to extract the first non-blank attribute value can be simplified. The current implementation is a bit convoluted with .orElse() and a separate if check. Using .ifPresent() on the Optional returned by findFirst() would make the code more concise, readable, and idiomatic for stream processing.
| String value = values.stream() | |
| .filter(StringUtils::isNotBlank) | |
| .findFirst() | |
| .orElse(values.get(0)); | |
| if (StringUtils.isNotBlank(value)) { | |
| attributes.put(attributeName, value); | |
| } | |
| values.stream() | |
| .filter(StringUtils::isNotBlank) | |
| .findFirst() | |
| .ifPresent(value -> attributes.put(attributeName, value)); |
Summary
Notes