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

De-duplicate user profile attribute values #2903

Merged
merged 2 commits into from
May 23, 2024

Conversation

rrenomeron-gov
Copy link
Contributor

I've discovered what I think is an issue with deserialization of the SAML2Profile class involving the authnContexts property. When it is deserialized, Jackson will populate the authenticationAttributes map in the object normally. But when it tries to populate the authnContexts property by calling its setter, it inserts a duplicate value into the authenticationAttributes map, as it tries to "merge" the multiple values.

As this happens on every read from JSON storage, the authenticationAttributes map gets really big really quickly (doubles on every serialization round trip). This causes big issues in my CAS ticket registry storage for a fairly common usage
pattern (user logs in to 5 or 6 different services on a single SSO session).

To fix, I made a small change to BasicUserProfile.mergeCollectionAttributes() which simply deduplicates multiple values from the two Collections. I'm thinking there's not a use case out there where somebody needs to have duplicate attribute values. I've done some testing in my nonproduction deployments, and it fixes the problem.

@leleuj leleuj merged commit ffeee2a into pac4j:master May 23, 2024
4 checks passed
@leleuj
Copy link
Member

leleuj commented May 23, 2024

Excellent! Thanks

@leleuj
Copy link
Member

leleuj commented May 24, 2024

I just cut the v6.0.3 release. It will show up soon in the Maven central repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants