Repository navigation
fix(getting-started): verify IAP JWT audience and issuer claims - #1912
Conversation
- 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 /.
There was a problem hiding this comment.
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.
| info = JWT.decode assertion, cert, true, | ||
| algorithm: "ES256", | ||
| aud: settings.audience, | ||
| verify_aud: true, | ||
| iss: "https://cloud.google.com/iap", | ||
| verify_iss: true |
There was a problem hiding this comment.
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
Pass:
to JWT.decode in getting-started/authenticating-users/app.rb.
b/586647638