Skip to content

Conversation

@bashhack
Copy link
Contributor

@bashhack bashhack commented Aug 31, 2025

Background

👋 @muhlemmer - hope all is well with you and the team!

AWS Cognito (and potentially other providers) return email_verified and phone_number_verified as strings ("true"/"false") instead of proper JSON booleans, violating the OIDC specification.

AWS Documentation confirms this:

Currently, Amazon Cognito returns the values for email_verified and phone_number_verified as strings.

Source: https://docs.aws.amazon.com/cognito/latest/developerguide/userinfo-endpoint.html#get-userinfo-response-sample

The Problem

The zitadel/oidc library currently handles this inconsistently:

This forces developers to handle semantically identical fields differently:

// Currently inconsistent code path
userInfo.EmailVerified = oidc.Bool(emailValue)    // Cast
userInfo.PhoneNumberVerified = phoneValue      // No cast

Additionally, the existing Bool.UnmarshalJSON implementation meant that false values couldn't overwrite true.

Solution

Applied Bool type consistently to both fields and simplified Bool.UnmarshalJSON using a direct switch statement to:

  • Handle standard JSON booleans (true/false)
  • Handle AWS Cognito string format ("true"/"false")
  • Return errors on invalid input instead of silently failing
  • Allow false to overwrite true

Updated tests to match codebase conventions, as well.

Impact

PhoneNumberVerified changes from bool to Bool (type alias of bool). Most consumer code should work as-is since Bool is just a type alias. Direct type assertions would need updating.

Definition of Ready

  • I am happy with the code
  • Short description of the feature/issue is added in the pr description
  • PR is linked to the corresponding user story
  • Acceptance criteria are met
  • All open todos and follow ups are defined in a new ticket and justified
  • Deviations from the acceptance criteria and design are agreed with the PO and documented.
  • No debug or dead code
  • My code has no repetitions
  • Critical parts are tested automatically
  • Where possible E2E tests are implemented
  • Documentation/examples are up-to-date
  • All non-functional requirements are met
  • Functionality of the acceptance criteria is checked manually on the dev system.

@bashhack bashhack force-pushed the fix/type-consistency-userinfo-response branch 2 times, most recently from f546b4f to 3bd4db0 Compare August 31, 2025 05:38
@bashhack bashhack mentioned this pull request Aug 31, 2025
13 tasks
@elinashoko elinashoko moved this to 📋 Sprint Backlog in Product Management Sep 1, 2025
@muhlemmer
Copy link
Collaborator

Breaking Changes

Please don't use this string in your PR comment. It get's converted to the commit message later and it will trigger the semrel tool to create a new major release.

@muhlemmer muhlemmer moved this from 📋 Sprint Backlog to 👀 In review in Product Management Sep 2, 2025
@elinashoko
Copy link

Heyo @bashhack checking if you'll have some time to come back to this PR?

@muhlemmer muhlemmer added the waiting For some reason, this issue will have to wait. This can be a feedback that is being waited for, a de label Sep 29, 2025
@bashhack
Copy link
Contributor Author

bashhack commented Oct 2, 2025

@elinashoko - yeah! Been swamped on my end, but should have time by end of this weekend to wrap this up - thanks for being so patient all 🤝

@bashhack bashhack force-pushed the fix/type-consistency-userinfo-response branch from 751e5ae to 7ace312 Compare October 4, 2025 04:53
@bashhack
Copy link
Contributor Author

bashhack commented Oct 4, 2025

@muhlemmer + @elinashoko - should be all set here, I think the end approach is a nice balance, thanks again! PR feedback implemented, and branch updated accordingly with main 🤝

Congrats on the 1.25+ support, too! 🎉

@elinashoko elinashoko removed the waiting For some reason, this issue will have to wait. This can be a feedback that is being waited for, a de label Oct 8, 2025
@elinashoko
Copy link

Thank you kindly @bashhack
@muhlemmer please have another look when you have a sec.

@muhlemmer muhlemmer self-requested a review October 22, 2025 09:12
Copy link
Collaborator

@muhlemmer muhlemmer left a comment

Choose a reason for hiding this comment

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

One more small comment and we are good to merge.

Comment on lines +20 to +22
//
// For broader historical context, see:
// - https://github.com/zitadel/oidc/pull/139
Copy link
Collaborator

Choose a reason for hiding this comment

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

No need to link the PR. If people want to find the source of a change, they can git blame.

Suggested change
//
// For broader historical context, see:
// - https://github.com/zitadel/oidc/pull/139

@elinashoko
Copy link

@bashhack pls have a look when you have a chance, let's get this over the line!

@elinashoko elinashoko added the waiting For some reason, this issue will have to wait. This can be a feedback that is being waited for, a de label Oct 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

os-contribution waiting For some reason, this issue will have to wait. This can be a feedback that is being waited for, a de

Projects

Status: 👀 In review

Development

Successfully merging this pull request may close these issues.

4 participants