Skip to content

feat: support federated OIDC login through the OAuth2 Authorization Server (#24050) - #24354

Merged
netroms merged 1 commit into
2.42from
backport-24050-2.42
Jul 8, 2026
Merged

feat: support federated OIDC login through the OAuth2 Authorization Server (#24050)#24354
netroms merged 1 commit into
2.42from
backport-24050-2.42

Conversation

@netroms

@netroms netroms commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Backport of #24050 to 2.42.
JIRA:DHIS2-21752

What

Fixes federated OIDC login through DHIS2's OAuth2 Authorization Server. After an external-IdP login ("Log in with Google"), reading the authorization at /oauth2/token returned HTTP 500, because the persisted principal (DhisOidcUser wrapping a UserDetailsImpl) is not on Spring Security's SecurityJackson2Modules deserialization allowlist.

The persistence layer now swaps the heavyweight DHIS2 principal for a lean, Spring-native UsernamePasswordAuthenticationToken (DHIS2 username + authorities) at the toEntity serialization boundary, so the persisted attributes round-trip with no custom Jackson mixins. This also fixes the federated flow end to end — the username/email claims previously carried the IdP sub.

Backport notes

  • Cherry-picked from master (cd398b5) with one trivial conflict in UserDetailsImpl.java: the PR deletes the unused userDetailsMixin Jackson factory, which on 2.42 lacked the dataViewMaxOrganisationUnitLevel parameter (that field does not exist on 2.42), so git could not auto-match the deletion. Resolved by accepting the deletion (the PR's intent). The only resulting difference from master's UserDetailsImpl is the pre-existing absence of the dataViewMaxOrganisationUnitLevel field on 2.42.
  • Spring Authorization Server on 2.42 is 1.5.5 — the exact version the fix was verified against in the original PR.
  • Confirmed the removed Jackson annotations are dead: userDetailsMixin is referenced nowhere, UserDetailsImpl is not Jackson-serialized elsewhere, and Redis Spring Session uses JDK serialization (not Jackson).
  • Verified locally: mvn test-compile of dhis-service-core, dhis-test-integration, dhis-test-web-apiBUILD SUCCESS; all three backported tests compile (LeanPrincipalTest, Dhis2OAuth2AuthorizationServiceIntegrationTest, FederatedOidcTokenControllerTest).

Original PR: #24050

AI Assisted

@sonarqubecloud

sonarqubecloud Bot commented Jul 2, 2026

Copy link
Copy Markdown

@netroms
netroms merged commit 93e3871 into 2.42 Jul 8, 2026
14 checks passed
@netroms
netroms deleted the backport-24050-2.42 branch July 8, 2026 08:23
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.

2 participants