Skip to content

Conversation

@pm990320
Copy link
Contributor

@pm990320 pm990320 commented Aug 21, 2025

Description

Fixes resumable uploads to respect the useAuthWithCustomEndpoint configuration flag when using custom API endpoints.

Problem

Currently, resumable uploads automatically bypass authentication for any non-googleapis.com domain, even when useAuthWithCustomEndpoint: true is explicitly set. This prevents using authenticated proxies or custom storage endpoints with resumable uploads.

Solution

  • Pass useAuthWithCustomEndpoint flag through to resumable upload configuration
  • Only bypass authentication if the flag is not explicitly set to true
  • Add useAuthWithCustomEndpoint property to Service class for proper type-safe access
  • Maintains backward compatibility with existing behavior

Changes Made

1. src/nodejs-common/service.ts

  • Added useAuthWithCustomEndpoint?: boolean to ServiceConfig interface
  • Added useAuthWithCustomEndpoint?: boolean property to Service class
  • Store the value in the Service constructor

2. src/file.ts

  • Pass useAuthWithCustomEndpoint from Storage to resumable upload config

3. src/resumable-upload.ts

  • Added useAuthWithCustomEndpoint?: boolean to UploadConfig interface
  • Modified authentication bypass logic to check the flag before bypassing auth

4. test/resumable-upload.ts

  • Added test: "should use authentication with custom endpoint when useAuthWithCustomEndpoint is true"
  • Added test: "should bypass authentication with custom endpoint when useAuthWithCustomEndpoint is false"
  • Added test: "should bypass authentication with custom endpoint when useAuthWithCustomEndpoint is undefined (backward compatibility)"

Testing

  • ✅ All new tests passing
  • ✅ Existing tests still pass
  • ✅ TypeScript compilation successful
  • ✅ Linting passed

Use Case

This fix is needed for:

  • Using authenticated proxies for GCS (e.g., nginx caching proxy with auth forwarding)
  • Corporate environments with custom storage gateways
  • Development environments with authenticated mock servers
  • Any scenario requiring resumable uploads through an authenticated intermediary

Backward Compatibility

✅ Fully maintained - when useAuthWithCustomEndpoint is undefined, the behavior remains unchanged (bypasses auth for custom endpoints)

Fixes resumable uploads to respect the useAuthWithCustomEndpoint configuration flag when using custom API endpoints.

Previously, resumable uploads would automatically bypass authentication for any non-googleapis.com domain, even when useAuthWithCustomEndpoint: true was explicitly set. This prevented using authenticated proxies or custom storage endpoints with resumable uploads.

Changes:
- Pass useAuthWithCustomEndpoint flag through to resumable upload configuration
- Only bypass authentication if the flag is not explicitly set to true
- Add useAuthWithCustomEndpoint property to Service class for proper access
- Maintains backward compatibility with existing behavior

Fixes #[issue-number]
@pm990320 pm990320 requested review from a team as code owners August 21, 2025 15:45
@product-auto-label product-auto-label bot added the size: m Pull request size is medium. label Aug 21, 2025
@google-cla
Copy link

google-cla bot commented Aug 21, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@product-auto-label product-auto-label bot added the api: storage Issues related to the googleapis/nodejs-storage API. label Aug 21, 2025
@ddelgrosso1
Copy link
Contributor

Thank you for the PR @pm990320. Before we review, do you mind signing the CLA?

@pm990320
Copy link
Contributor Author

Thank you for the PR @pm990320. Before we review, do you mind signing the CLA?

Hey @ddelgrosso1 - I have now signed the CLA.

@ddelgrosso1 ddelgrosso1 added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Aug 22, 2025
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Aug 22, 2025
@ddelgrosso1 ddelgrosso1 added the owlbot:run Add this label to trigger the Owlbot post processor. label Aug 22, 2025
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Aug 22, 2025
@ddelgrosso1 ddelgrosso1 merged commit 707b4f2 into googleapis:main Aug 27, 2025
16 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: storage Issues related to the googleapis/nodejs-storage API. size: m Pull request size is medium.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants