Conversation
There was a problem hiding this comment.
Code Review
This pull request replaces the use of the google-cloud-iamcredentials library with manual HTTP requests to the IAM API for fetching IAP tokens. The review highlights several critical issues: the current Gson version (2.8.5) is incompatible with the newly introduced JsonParser.parseString method, the fetchIapToken method lacks thread safety, and the manual construction of API requests introduces risks regarding URL encoding and JSON formatting. It is recommended to upgrade the Gson dependency, implement thread synchronization, and reconsider the use of the official SDK to ensure reliability and maintainability.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request replaces the Google Cloud IAM library with a manual implementation using the standard Java HttpClient and the Google Auth OAuth2 library to generate IAP tokens. It also updates the Gson dependency and introduces thread synchronization for token fetching. Feedback highlights a performance issue where configuration lookups are repeated unnecessarily when IAP is disabled, and suggests using the non-deprecated URLEncoder.encode method to avoid deprecation warnings.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request refactors IAP token retrieval by replacing the google-cloud-iamcredentials library with manual HTTP requests via java.net.http.HttpClient. It introduces thread-safe token fetching, a 5-minute expiration buffer, and updates the gson dependency. A potential NullPointerException was identified when accessing the Google access token, and a null-safe implementation was suggested to improve robustness.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request replaces the google-cloud-iamcredentials library with a manual implementation using Java's HttpClient to fetch IAP tokens. It also updates the gson dependency and introduces a synchronization mechanism and a 5-minute buffer for token expiration. Review feedback suggests using asynchronous HTTP requests to prevent blocking and implementing more specific error handling for JSON parsing to improve debuggability.
| throw RuntimeException("IAM API Error: ${iapResponse.statusCode()} - ${iapResponse.body()}") | ||
| } | ||
|
|
||
| val iapJsonObject = JsonParser.parseString(iapResponse.body()).asJsonObject |
There was a problem hiding this comment.
This PR adds support for routing API requests through Identity-Aware Proxy. This is done by putting an OIDC token in the header as
Proxy-Authorization: Bearer <token>. The OIDC is generated without IamCredentialsClient libraryTo use, users need to provide their
iap_client_idandiap_service_account_emailto the SDK's configuration payload.iap_client_idis the OAuth client ID that was set-up when configuring the the identity-aware proxy.iap_service_account_emailis the service account that is authorized to bypass IAP.