Skip to content

Compare sub claims as strings in validate_user_claim - #704

Merged
daggerhart merged 2 commits into
oidc-wp:developfrom
SAY-5:fix-integer-sub-user-claim
Nov 20, 2026
Merged

daggerhart merged 2 commits into
oidc-wp:developfrom
SAY-5:fix-integer-sub-user-claim

Conversation

@SAY-5

@SAY-5 SAY-5 commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

All Submissions:

Changes proposed in this Pull Request:

validate_user_claim() compares the id_token sub and the userinfo sub with !==, so an IdP that returns "35" in the id_token and 35 in the userinfo response fails with incorrect-user-claim. This compares both values as strings, the same way validate_existing_user_link() already compares identities. I don't have a miniOrange server to test against, so I reproduced it with the reporter's debug values in a unit test.

Closes #673 .

How to test the changes in this Pull Request:

  1. Run composer phpunit -- --filter test_validate_user_claim_with_integer_sub.
  2. Before the change validate_user_claim( array( 'sub' => 35 ), array( 'sub' => '35' ) ) returns incorrect-user-claim; after the change it returns true.
  3. A different sub value is still refused with incorrect-user-claim.

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully run tests with your changes locally?

Changelog entry

Fix the incorrect-user-claim login error when the IdP returns sub as an integer in the userinfo response.

Signed-off-by: Sai Asish Y <say.apm35@gmail.com>

@daggerhart daggerhart left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great. Thanks for the help!

@daggerhart
daggerhart merged commit 34b7bfa into oidc-wp:develop Nov 20, 2026
9 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.

Bug: validate_user_claim fails with strict comparison when sub is integer in userinfo response

2 participants