Skip to content

Harden gcloud credential injection and add upstream error diagnostics - #27

Merged
bbrowning merged 1 commit into
mainfrom
gcloud-cred-debugging
Jul 23, 2026
Merged

Harden gcloud credential injection and add upstream error diagnostics#27
bbrowning merged 1 commit into
mainfrom
gcloud-cred-debugging

Conversation

@bbrowning

Copy link
Copy Markdown
Owner

Prevent the GCloudInjector's token refresh from accidentally routing through the proxy's own token vendor (which returns dummy tokens) by setting Proxy: nil on the HTTP transport. Add a guard that rejects synthetic/short tokens before injection, and diagnostic logging (GCLOUD_TOKEN_DEBUG, UPSTREAM_ERROR) to distinguish proxy-generated errors from upstream errors when debugging 401s.

  • Set Proxy: nil on GCloudInjector and ChatGPTInjector HTTP transports
  • Reject tokens matching SyntheticToken or shorter than 20 chars
  • Extract SyntheticToken constant shared between token vendor and guard
  • Add OnResponse handler logging upstream 4xx/5xx for injected requests
  • Add integration test: upstream 429/500/503 pass through unchanged
  • Add unit tests: GCloudInjector never returns InjectAuthRequired
  • Add != 401 assertion to credential injection failure test

Prevent the GCloudInjector's token refresh from accidentally routing
through the proxy's own token vendor (which returns dummy tokens) by
setting Proxy: nil on the HTTP transport. Add a guard that rejects
synthetic/short tokens before injection, and diagnostic logging
(GCLOUD_TOKEN_DEBUG, UPSTREAM_ERROR) to distinguish proxy-generated
errors from upstream errors when debugging 401s.

- Set Proxy: nil on GCloudInjector and ChatGPTInjector HTTP transports
- Reject tokens matching SyntheticToken or shorter than 20 chars
- Extract SyntheticToken constant shared between token vendor and guard
- Add OnResponse handler logging upstream 4xx/5xx for injected requests
- Add integration test: upstream 429/500/503 pass through unchanged
- Add unit tests: GCloudInjector never returns InjectAuthRequired
- Add != 401 assertion to credential injection failure test

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@bbrowning
bbrowning merged commit c5d1fc9 into main Jul 23, 2026
6 checks passed
@bbrowning
bbrowning deleted the gcloud-cred-debugging branch July 23, 2026 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant