You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The storage client doesn't behave correctly when a service account key or token is supplied via the credentials parameter, but the project_id is not provided. In this case, it falls backs to searching for credentials.
There's two issues with the implementation:
The project_id docstring says it will be inferred from the environment if omitted. If credentials contains a service account key, that search should include the data in the key (it contains the correct project id).
If other credentials are found, the client silently loads them. This is very surprising, and could result in security issues when multiple credentials are available. (I discovered this when the client autoloaded my SDK credentials despite being provided a service account key.)
Ideally, if credentials is not None, the client should disable all searches and just use the provided info. If those creds fail, subsequent requests should fail.
If this is impossible due to being an API incompatibility, then a warning should be issued to tell the user that the provided credentials were ignored.
Environment details
OS type and version: Debian buster
Python version: Python 3.7.7
pip version: pip 20.1.1 from /usr/local/lib/python3.7/site-packages/pip (python 3.7)
google-cloud-storage version: 1.29.0
Steps to reproduce
Create a service account and a key or token.
Instantiate a client using that credential without specifying project_id.
Code example
Example showing that it falls back to default search even when a key is provided:
The storage client doesn't behave correctly when a service account key or token is supplied via the
credentials
parameter, but theproject_id
is not provided. In this case, it falls backs to searching for credentials.There's two issues with the implementation:
The
project_id
docstring says it will be inferred from the environment if omitted. Ifcredentials
contains a service account key, that search should include the data in the key (it contains the correct project id).If other credentials are found, the client silently loads them. This is very surprising, and could result in security issues when multiple credentials are available. (I discovered this when the client autoloaded my SDK credentials despite being provided a service account key.)
Ideally, if
credentials
is notNone
, the client should disable all searches and just use the provided info. If those creds fail, subsequent requests should fail.If this is impossible due to being an API incompatibility, then a warning should be issued to tell the user that the provided credentials were ignored.
Environment details
Python 3.7.7
pip 20.1.1 from /usr/local/lib/python3.7/site-packages/pip (python 3.7)
google-cloud-storage
version: 1.29.0Steps to reproduce
project_id
.Code example
Example showing that it falls back to default search even when a key is provided:
To see the silent fallback, run this in an environment where you've done
gcloud auth application-default
.The text was updated successfully, but these errors were encountered: