feat(auth): sync OIDC user properties#12378
Open
AnneGerlach wants to merge 1 commit intoIQSS:developfrom
Open
Conversation
Contributor
|
@pdurbin @poikilotherm another feature from us ;) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does / why we need it:
This PR adds synchronization of user properties from the OIDC identity provider to the Dataverse
AuthenticatedUser.Currently, Dataverse authenticates users via bearer tokens but does not persist updated user properties from the OIDC provider. This can lead to outdated user data (e.g. incorrect email addresses), which becomes problematic for features such as notifications or user-facing metadata.
This implementation follows a comparison-based approach:
OAuth2UserRecord(OIDC / Keycloak) are compared with the storedAuthenticatedUserThe following fields are synchronized:
firstNamelastNameemailIn addition, this PR synchronizes the OIDC
email_verifiedclaim with Dataverse’s internal representation of email verification (emailConfirmedtimestamp).Mapping:
email_verified = true→ setemailConfirmedtimestampemail_verified = false→ setemailConfirmedtonullThis PR also addresses a small UI inconsistency:
(See screenshots below)
Dataverse keeps the
AuthenticatedUserin the session, which can lead to stale values being displayed in the Account Information page even after the database has been updated.To resolve this:
session.setUser(...), which would otherwise invalidate the session/view state🏴 The feature is controlled via a feature flag:
dataverse.feature.oidc-user-property-syncWhich issue(s) this PR closes:
groupsclaim to user groups #9969Special notes for your reviewer:
email_verifiedclaim is treated as optional to ensure compatibility with providers that do not expose this claimdisplayInfo.emailand falls back to available email addresses if neededAlternative approaches were considered:
Timestamp-based sync (
updated_atclaim)Not feasible, as this claim is not provided by Keycloak by default and would require schema changes
Push-based updates from the IdP
Not suitable, as the backend should not depend on external triggers or actively query the identity provider
👉 Therefore, a comparison-based approach was chosen to keep the implementation simple and compatible with any OIDC provider
Suggestions on how to test this:
Run all tests:
mvn testor only the relevant ones in:
mvn -Dtest=AuthenticationServiceBeanTest testOptional manual verification:
Before testing, ensure that an OIDC authentication provider is configured (in my case Keycloak).
curl -i \ -H "Authorization: Bearer $TOKEN" \ http://localhost:8080/api/users/:meExpected:
Example response:
{ "status": "OK", "data": { "id": 2, "identifier": "@user", "displayName": "NewFirst NewLast", "firstName": "NewFirst", "lastName": "NewLast", "email": "newemail-user@mailinator.com", ... } }🤝 If helpful, I can provide a more detailed step-by-step manual test guide.
Does this PR introduce a user interface change? If mockups are available, please link/include them here:
No new UI is introduced.
However, this PR fixes an issue where the Account Information page could display stale user data after OIDC updates.
Before:

After:

Is there a release notes update needed for this change?:
Yes, a release note has been added: doc/release-notes/10266-oidc-property-sync.md
Additional documentation:
Documentation for the new feature flag has been added to the configuration guide.
Thanks for reviewing 🌻