Skip to content

fix(storage): skip authentication for custom endpoints by default - #9982

Open
thiyaguk09 wants to merge 2 commits into
googleapis:mainfrom
thiyaguk09:fix/storage-custom-endpoint-auth
Open

thiyaguk09 wants to merge 2 commits into
googleapis:mainfrom
thiyaguk09:fix/storage-custom-endpoint-auth

Conversation

@thiyaguk09

Copy link
Copy Markdown
Contributor

Skip Google authentication, universe domain checks, and ADC project ID lookups for custom and emulator endpoints unless useAuthWithCustomEndpoint is explicitly set to true.

  • Forward customEndpoint, useAuthWithCustomEndpoint, and projectIdRequired: false from Storage to StorageTransport.
  • Bypass GoogleAuth and assertUniverseDomain in StorageTransport#makeRequest on unauthenticated custom endpoints, dispatching via plain Gaxios while preserving defaults, interceptors, retries, timeouts, headers, streaming, and error decoration.
  • Resolve explicit projectId / {{projectId}} tokens without calling getProjectId(), strip unresolved exact-placeholder query params, reject unresolved path/embedded tokens, and preserve falsy primitive query values while stripping empty query objects.
  • Guard assertUniverseDomain in File#createWriteStream for simple (resumable: false) uploads on unauthenticated custom endpoints.
  • Update XMLMultiPartUploadHelper in TransferManager to use plain Gaxios and skip assertUniverseDomain on unauthenticated custom endpoints.

Fixes #9873

Skip Google authentication, universe domain checks, and ADC project ID lookups for custom and emulator endpoints unless useAuthWithCustomEndpoint is explicitly set to true.

- Forward customEndpoint, useAuthWithCustomEndpoint, and projectIdRequired: false from Storage to StorageTransport.
- Bypass GoogleAuth and assertUniverseDomain in StorageTransport#makeRequest on unauthenticated custom endpoints, dispatching via plain Gaxios while preserving defaults, interceptors, retries, timeouts, headers, streaming, and error decoration.
- Resolve explicit projectId / {{projectId}} tokens without calling getProjectId(), strip unresolved exact-placeholder query params, reject unresolved path/embedded tokens, and preserve falsy primitive query values while stripping empty query objects.
- Guard assertUniverseDomain in File#createWriteStream for simple (resumable: false) uploads on unauthenticated custom endpoints.
- Update XMLMultiPartUploadHelper in TransferManager to use plain Gaxios and skip assertUniverseDomain on unauthenticated custom endpoints.

Fixes googleapis#9873
@product-auto-label product-auto-label Bot added the api: storage Issues related to the Cloud Storage API. label Nov 26, 2026

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

Copy link
Copy Markdown
Contributor

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 introduces support for unauthenticated custom endpoints (such as local emulators) and dynamic {{projectId}} placeholder resolution across the Storage client, Transport, and Transfer Manager. Two key feedback points were raised: first, when creating a new Gaxios instance for unauthenticated custom endpoints in transfer-manager.ts, custom interceptors from the transport's gaxiosInstance should be copied over to avoid bypassing user-configured interceptors; second, in storage-transport.ts, queryParameters in baseRequestOpts should be explicitly overridden with the resolved queryParameters object to ensure downstream code does not see unresolved placeholders.

- Pass resolved and stripped queryParameters on request options in StorageTransport#makeRequest so interceptors observe normalized values on config.queryParameters.
- Copy request and response interceptors from storageTransport.gaxiosInstance and omit defaults.adapter when constructing the unauthenticated Gaxios requester in XMLMultiPartUploadHelper.
- Add unit tests for both behaviors in storage-transport and transfer-manager.
@thiyaguk09
thiyaguk09 marked this pull request as ready for review November 27, 2026 06:44
@thiyaguk09
thiyaguk09 requested review from a team as code owners November 27, 2026 06:44

This branch has not been deployed

No deployments
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 Cloud Storage API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

storage 9.0.0: a custom apiEndpoint always authenticates now (useAuthWithCustomEndpoint is ignored), so emulators need credentials

1 participant