GoogleCloudPlatform / gsutil

A command line tool for interacting with cloud storage services.
Apache License 2.0
864 stars 331 forks source link

Allow accessing public data with anonymous user when shim is turned ON #1755

Closed dilipped closed 8 months ago

dilipped commented 8 months ago

Accessing public data does not require authentication. In gsutil, this works out-of-the-box. In gcloud storage, the user has to set auth/disable_credentials property to use it without authentication (i.e without setting up an active account). For the shim, in order to not break the workflow of existing users who rely on the gsutil behavior, we will set the auth/disable_credentials property automatically if we detect that gcloud doesn't have any active account configured.

The change has been tested manually

Before:

$ CLOUDSDK_CORE_PASS_CREDENTIALS_TO_GSUTIL=1 GCLOUD_BINARY_PATH=/usr/bin/gcloud python3 gsutil.py -o "GSUtil:use_gcloud_storage=True"  ls  gs://pub/test.txt
ERROR: (gcloud.storage.ls) You do not currently have an active account selected.
Please run:

  $ gcloud auth login

to obtain new credentials.

If you have already logged in with a different account, run:

  $ gcloud config set account ACCOUNT

to select an already authenticated account to use.

After:

$ CLOUDSDK_CORE_PASS_CREDENTIALS_TO_GSUTIL=1 GCLOUD_BINARY_PATH=/usr/bin/gcloud python3 gsutil.py -o "GSUtil:use_gcloud_storage=True"  ls  gs://pub/test.txt
gs://pub/test.txt
dilipped commented 8 months ago

All kokoro failures are because of known issues. We had a bug filed for one of them. I filed a couple of new bugs to track the other kokoro failures.