Skip to content

Enhance 'unauthenticated' auth type for GCS storage #26984

@szisiu

Description

@szisiu

This is related to

What your current code does (v477)

In GcsServiceAccountAuth, if neither jsonKey nor jsonKeyFilePath is supplied and ADC cannot be resolved, the catch block returns null, so we simply never call builder.setCredentials(...). That means the Storage client is built with credentials == null. In practice, the google-cloud-storage library will then send requests without an Authorization header.

Potential downsides of just “null”

  • Silent failure: If you accidentally run against real GCS (not eg a fake server) and no credentials are available, you won’t see an early, explicit error; you’ll just get 401/403 when making calls.
  • Repeated ADC attempts: In some library versions, constructing clients or performing certain operations may retry ADC resolution internally, adding overhead or noisy logs (to be verified in the current version).
  • Ambiguity: It’s not obvious to a future reader that “null” was intentionally used to mean “unauthenticated mode.”

Proposal

  • Prefer explicit NoCredentials for clarity. The GCS library provides NoCredentials.getInstance(). This documents intent and prevents future code paths from trying to refresh tokens.
  • We could add NoCredentials to GcsServiceAccountAuth
  • We could add a new GcsNoAuth auth type that is configurable with UNAUTHENTICATED (in GcsFileSystemConfig)

WDYT?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions