Skip to content

fix: improve oidc identity mapping and sync developer email - #348

Merged
learnerjohn merged 3 commits into
higress-group:mainfrom
wzlee:fix/oidc-nested-claim-mapping
Oct 19, 2026
Merged

learnerjohn merged 3 commits into
higress-group:mainfrom
wzlee:fix/oidc-nested-claim-mapping

Conversation

@wzlee

@wzlee wzlee commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

📝 Description

Some identity providers wrap user info in an envelope such as Feishu's {"code":0,"data":{...}}. Flat claim lookup cannot resolve fields such as data.open_id, causing login to fail. Existing OIDC accounts also retain an empty email after email mapping is configured, and the profile result previously omitted email.

  • Support dot-separated identity mapping fields in OIDC and OAuth2 through ClaimUtils.resolveClaim, while preserving exact top-level claim precedence for keys containing dots.
  • Reject empty segments when resolving nested paths, including data., ., and data..open_id, so malformed paths cannot resolve to an entire object or an empty-key claim. Exact top-level keys remain supported.
  • Sync nonblank email and avatar values into existing developer records on OIDC login, without overwriting stored values with blanks or saving unchanged profiles.
  • Expose email in DeveloperResult and clarify the identity mapping error for missing user IDs or names.

✅ Type of Change

  • Bug fix (non-breaking change)
  • New feature (non-breaking change)
  • Breaking change
  • Documentation update
  • Code refactoring
  • Performance improvement
  • Test improvement

🧪 Testing

  • ClaimUtilsTest and DeveloperServiceImplProfileTest: 29 tests pass, covering nested mapping, literal top-level precedence, empty path segments, email backfill, blank-value preservation, unchanged profiles, and missing identities.
  • ./scripts/code-check.sh backend passes.
  • Clean temporary merge with the latest main; ./mvnw -q verify passes with 234 tests, zero failures, zero errors, and zero skipped tests.
  • git diff --check passes.
  • Manual verification reported by the contributor: Feishu OIDC with accounts.feishu.cn authorize/token endpoints and authen/v1/user_info, using data.open_id / data.name / data.email / data.avatar_url, supports registration, repeated-login email backfill, and portal profile email display.

📋 Checklist

  • Code has been formatted.
  • Code is self-reviewed.
  • No breaking changes.
  • Relevant regression tests added.

@CLAassistant

CLAassistant commented Sep 28, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@wzlee
wzlee force-pushed the fix/oidc-nested-claim-mapping branch from bc5a75c to 75768ed Compare September 28, 2026 09:52
Some identity providers wrap user info in an envelope instead of
returning flat OIDC claims. For example, Feishu's authen v1 user_info
API responds with {"code":0,"data":{...},"msg":"success"}, so the flat
Map.get() lookup on identity mapping fields (sub/name by default) never
matches and login fails with "Missing user ID or user name in ID Token"
even though the user info was fetched successfully.

- Add ClaimUtils.resolveClaim: top-level claim keys are matched first
  for backward compatibility; otherwise dot-separated fields such as
  data.open_id are resolved as nested paths
- Apply it to identity field extraction in OidcServiceImpl and
  OAuth2ServiceImpl (userId/userName/email/avatarUrl)
- Add unit tests covering flat claims, nested envelopes, dotted
  top-level keys, and invalid paths

With this change, Feishu OIDC login works by configuring the identity
mapping as data.open_id / data.name / data.email / data.avatar_url.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: lizw2 <214508914@qq.com>
@wzlee
wzlee force-pushed the fix/oidc-nested-claim-mapping branch from 75768ed to d1646c1 Compare September 28, 2026 11:08
@wzlee wzlee changed the title fix: support dot-path identity mapping for nested oidc claims fix: improve oidc identity mapping and sync developer email Sep 29, 2026
- sync email (with avatar) into the existing developer on each OIDC login, so accounts created before the email mapping was configured get backfilled

- expose email in DeveloperResult so the portal profile page can display it

- clarify the error message when identity mapping yields no user ID or name

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: lizw2 <214508914@qq.com>
@wzlee
wzlee force-pushed the fix/oidc-nested-claim-mapping branch from 803d781 to 16209ee Compare September 29, 2026 08:00
Signed-off-by: zhaoh <yanyan.zh@alibaba-inc.com>
@learnerjohn
learnerjohn self-requested a review October 19, 2026 06:34
@learnerjohn
learnerjohn merged commit 6f86436 into higress-group:main Oct 19, 2026
11 of 14 checks 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