fix: handle email_verified as JSON string or boolean in OidcUser#502
Open
shoichi1023 wants to merge 3 commits intolejianwen:masterfrom
Open
fix: handle email_verified as JSON string or boolean in OidcUser#502shoichi1023 wants to merge 3 commits intolejianwen:masterfrom
shoichi1023 wants to merge 3 commits intolejianwen:masterfrom
Conversation
added 3 commits
March 6, 2026 16:08
Some OIDC providers such as Amazon Cognito return the email_verified
claim as a JSON string ("true"/"false") instead of a JSON boolean,
which violates the OIDC Core spec (section 5.1).
Change VerifiedEmail field type from bool to json.RawMessage and use
strings.Trim to normalize both representations before comparison.
… for email_verified - Use strings.EqualFold to handle "True"/"TRUE" from non-standard providers - Document nil/absent field behavior (defaults to false) in comment - Add oauth_test.go covering bool, string, case-insensitive, null, and absent cases
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.
Problem
Some OIDC providers (e.g. Amazon Cognito) return
email_verifiedas a JSON string ("true"/"false") instead of a JSON boolean, which violates OIDC Core spec section 5.1.This caused the following error at login:
Fix
Change
OidcUser.VerifiedEmailfrombooltojson.RawMessage, which accepts any JSON value without type errors. Then normalize both representations usingstrings.EqualFold+strings.Trimto handle:true/false"true"/"false"/"True"/"TRUE"(case-insensitive)nullor absent field → defaults tofalseTests
Added
model/oauth_test.gocovering all the above cases.