Skip to content

identity/oidc: omit null and empty string claims from provider tokens#32000

Open
emmayusufu wants to merge 1 commit into
hashicorp:mainfrom
emmayusufu:oidc-omit-empty-claims
Open

identity/oidc: omit null and empty string claims from provider tokens#32000
emmayusufu wants to merge 1 commit into
hashicorp:mainfrom
emmayusufu:oidc-omit-empty-claims

Conversation

@emmayusufu

Copy link
Copy Markdown

Fixes #13936.

When an OIDC scope template references entity metadata that is missing, Vault currently returns the claim with an empty string value in the ID token and UserInfo response (for example "name": ""). The OIDC spec (Core 5.3.2) says a claim that is not returned should be omitted rather than sent with a null or empty string value.

This omits claims whose value is null or an empty string when merging scope templates, in mergeJSONTemplates. That function is the shared path for both the ID token (generatePayload) and the UserInfo response, so the behaviour is consistent across both. Empty lists and objects are preserved, since an empty collection is a meaningful value (for example a groups claim with no groups).

Added a unit test covering the omitted and preserved cases.

@emmayusufu
emmayusufu requested review from a team as code owners June 17, 2026 12:34
@emmayusufu
emmayusufu requested a review from suraj-simha June 17, 2026 12:34
@vercel

vercel Bot commented Jun 17, 2026

Copy link
Copy Markdown

Deployment failed with the following error:

The `vercel.json` schema validation failed with the following message: should NOT have additional property `public`

Learn More: https://vercel.com/docs/concepts/projects/project-configuration

@dosubot dosubot Bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Jun 17, 2026
@vercel

vercel Bot commented Jun 17, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
vault-ui Error Error Jun 17, 2026 12:35pm

Request Review

When an OIDC scope template references entity metadata that is missing, Vault returns the claim with an empty string value in the ID token and UserInfo response. The OIDC spec says a claim that is not returned should be omitted rather than sent with a null or empty string value.

Omit claims whose value is null or an empty string when merging scope templates in mergeJSONTemplates, the shared path for both the ID token and the UserInfo response. Empty lists and objects are preserved, since an empty collection is a meaningful value.

Fixes hashicorp#13936
@emmayusufu

Copy link
Copy Markdown
Author

@austingebauer this implements the empty-claims exclusion you welcomed in #13936. The fix is in mergeJSONTemplates (the shared ID-token and UserInfo path), dropping null and empty-string claims while keeping empty lists and objects, with a unit test and a changelog entry. CLA is signed and it's mergeable. The only red check is the Vercel docs preview failing on vercel.json schema, which isn't related to this change. Would you be able to take a look when you have a moment?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

identity/oidc size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OIDC Provider - exclude empty claims

1 participant