Repository navigation
fix(cli): require a boolean email_verified claim in GoogleOidcVerifier - #7295
Closed
vishal-bulbule wants to merge 2 commits into
Closed
vishal-bulbule wants to merge 2 commits into
vishal-bulbule wants to merge 2 commits into
Conversation
The allowlist check in GoogleOidcVerifier tested the email_verified claim with Python truthiness, so any non-empty string such as "false" counted as verified when the email was on the allowlist. OpenID Connect defines email_verified as a JSON boolean, so the check now requires the value to be exactly True. Google-issued ID tokens already carry a boolean; this closes the gap for any other claim shape. Fixes google#7289
vishal-bulbule
force-pushed
the
fix/oidc-email-verified-bool
branch
from
September 28, 2026 07:39
f190a9e to
aaa1a39
Compare
Collaborator
|
Thank you @vishal-bulbule for your contribution! 🎉 Your changes have been successfully imported and merged via Copybara in commit 4434070. Closing this PR as the changes are now in the main branch. |
4 tasks done
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.
Link to Issue or Description of Change
Link to an existing issue:
Problem:
GoogleOidcVerifierchecks theemail_verifiedclaim with Python truthiness (not claims.get("email_verified")). Any non-empty string, including"false", and any non-zero number counts as verified when the email is on the allowlist. OpenID Connect definesemail_verifiedas a JSON boolean.Solution:
Require the claim to be exactly
True(claims.get("email_verified") is not Truerejects everything else). Google-issued ID tokens already carry a boolean, so behaviour for real tokens is unchanged; the change closes the gap for any other claim shape. One line insrc/google/adk/cli/trigger_routes.py, plus parametrized unit tests.Testing Plan
Unit Tests:
New test
test_rejects_non_boolean_email_verifiedintests/unittests/cli/test_trigger_routes.py, parametrized over"false","true"and1for both trigger endpoints (Pub/Sub and Eventarc).New test
test_rejects_missing_or_null_email_verified, covering an absent claim and an explicit null on both endpoints (cases from #7309). These already return 403 on main, so they pin that behavior rather than prove the fix.Against main (tests only, no fix):
With the fix, rebased onto main 044a1ec, whole file:
pre-commit run --fileson both files: clean. On the first revision,tox(py310 to py314): py310, py311 and py313 pass the full unit suite (16146, 16155 and 16146 passed). py312 and py314 each report 2 failures intest_import_loading.py::test_entry_point_loads_only_allowlisted_packages[agent|runner]aboutsitecustomize. Both come from thesitecustomize.pythat Homebrew ships inside its python@3.12 and python@3.14 installs, reproduce on unpatched main, and do not occur on uv-managed 3.12.14 and 3.14.7 (92 passed for the import-loading and trigger_routes test files on each).Manual End-to-End (E2E) Tests:
Script that builds a
GoogleOidcVerifier(audience=..., allowed_emails=["allowed@project.iam"]), patchesgoogle_id_token.verify_oauth2_tokento return a claim set with the givenemail_verified, and calls the verifier with a bearer header.On main (9a33588):
With this change:
Checklist
Additional context
adk-go applies the same boolean requirement in its Google OIDC authenticator (
server/authn/googleoidc.go).