Skip to content

fix(getting-started): verify IAP JWT audience and issuer claims - #1912

Merged
quartzmo merged 1 commit into
GoogleCloudPlatform:mainfrom
quartzmo:fix-iap-jwt-verify
Nov 24, 2026
Merged

quartzmo merged 1 commit into
GoogleCloudPlatform:mainfrom
quartzmo:fix-iap-jwt-verify

Conversation

@quartzmo

Copy link
Copy Markdown
Member

Pass:

to JWT.decode in getting-started/authenticating-users/app.rb.

b/586647638

- Pass verify_aud: true, iss: "https://cloud.google.com/iap", and verify_iss: true to JWT.decode in getting-started/authenticating-users/app.rb.
- Add hermetic Minitest unit tests for validate_assertion and GET /.
@quartzmo
quartzmo requested review from a team as code owners November 24, 2026 23:04
@product-auto-label product-auto-label Bot added the samples Issues that are directly related to samples. label Nov 24, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request adds testing dependencies to the Gemfile, introduces a comprehensive test suite for the authenticating-users application, and strengthens JWT validation in app.rb by explicitly verifying the issuer and audience. Feedback suggests updating the deprecated singular algorithm option in JWT.decode to the plural algorithms array option to ensure compatibility with newer versions of the jwt gem.

Comment on lines +63 to +68
info = JWT.decode assertion, cert, true,
algorithm: "ES256",
aud: settings.audience,
verify_aud: true,
iss: "https://cloud.google.com/iap",
verify_iss: true

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The jwt gem (especially in version 2.x and later) expects the algorithms (plural) option as an array of allowed algorithms (e.g., algorithms: ["ES256"]) rather than the singular algorithm option.\n\nUsing the singular algorithm option is deprecated and may be ignored or cause errors in newer versions of the gem. Updating this to algorithms: ["ES256"] ensures compatibility and adheres to the standard usage of the library.

  info = JWT.decode assertion, cert, true,\n                    algorithms: ["ES256"],\n                    aud: settings.audience,\n                    verify_aud: true,\n                    iss: "https://cloud.google.com/iap",\n                    verify_iss: true

@quartzmo
quartzmo merged commit ffe092c into GoogleCloudPlatform:main Nov 24, 2026
10 checks passed
@quartzmo
quartzmo deleted the fix-iap-jwt-verify branch November 24, 2026 23:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

samples Issues that are directly related to samples.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants