google-auth 2.45.0__tar.gz → 2.46.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {google_auth-2.45.0/google_auth.egg-info → google_auth-2.46.0}/PKG-INFO +1 -2
- {google_auth-2.45.0 → google_auth-2.46.0}/google/auth/_cloud_sdk.py +1 -1
- {google_auth-2.45.0 → google_auth-2.46.0}/google/auth/_default.py +18 -5
- {google_auth-2.45.0 → google_auth-2.46.0}/google/auth/_refresh_worker.py +2 -2
- {google_auth-2.45.0 → google_auth-2.46.0}/google/auth/aio/transport/aiohttp.py +1 -1
- {google_auth-2.45.0 → google_auth-2.46.0}/google/auth/aio/transport/sessions.py +1 -1
- {google_auth-2.45.0 → google_auth-2.46.0}/google/auth/aws.py +10 -9
- {google_auth-2.45.0 → google_auth-2.46.0}/google/auth/compute_engine/_metadata.py +22 -12
- {google_auth-2.45.0 → google_auth-2.46.0}/google/auth/compute_engine/credentials.py +1 -3
- {google_auth-2.45.0 → google_auth-2.46.0}/google/auth/credentials.py +3 -3
- {google_auth-2.45.0 → google_auth-2.46.0}/google/auth/external_account.py +4 -3
- {google_auth-2.45.0 → google_auth-2.46.0}/google/auth/external_account_authorized_user.py +11 -10
- {google_auth-2.45.0 → google_auth-2.46.0}/google/auth/identity_pool.py +10 -9
- {google_auth-2.45.0 → google_auth-2.46.0}/google/auth/impersonated_credentials.py +9 -2
- {google_auth-2.45.0 → google_auth-2.46.0}/google/auth/jwt.py +1 -2
- {google_auth-2.45.0 → google_auth-2.46.0}/google/auth/metrics.py +2 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/google/auth/pluggable.py +10 -9
- {google_auth-2.45.0 → google_auth-2.46.0}/google/auth/transport/_aiohttp_requests.py +1 -3
- {google_auth-2.45.0 → google_auth-2.46.0}/google/auth/transport/_http_client.py +0 -1
- {google_auth-2.45.0 → google_auth-2.46.0}/google/auth/transport/grpc.py +5 -5
- {google_auth-2.45.0 → google_auth-2.46.0}/google/auth/transport/mtls.py +8 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/google/auth/transport/requests.py +9 -3
- {google_auth-2.45.0 → google_auth-2.46.0}/google/auth/transport/urllib3.py +9 -5
- {google_auth-2.45.0 → google_auth-2.46.0}/google/auth/version.py +1 -1
- {google_auth-2.45.0 → google_auth-2.46.0}/google/oauth2/_client.py +10 -4
- {google_auth-2.45.0 → google_auth-2.46.0}/google/oauth2/_client_async.py +5 -1
- {google_auth-2.45.0 → google_auth-2.46.0}/google/oauth2/_id_token_async.py +4 -2
- {google_auth-2.45.0 → google_auth-2.46.0}/google/oauth2/_reauth_async.py +5 -3
- {google_auth-2.45.0 → google_auth-2.46.0}/google/oauth2/credentials.py +5 -2
- {google_auth-2.45.0 → google_auth-2.46.0}/google/oauth2/id_token.py +9 -7
- {google_auth-2.45.0 → google_auth-2.46.0}/google/oauth2/reauth.py +5 -1
- {google_auth-2.45.0 → google_auth-2.46.0}/google/oauth2/service_account.py +1 -2
- {google_auth-2.45.0 → google_auth-2.46.0}/google/oauth2/webauthn_handler.py +1 -1
- {google_auth-2.45.0 → google_auth-2.46.0/google_auth.egg-info}/PKG-INFO +1 -2
- {google_auth-2.45.0 → google_auth-2.46.0}/google_auth.egg-info/SOURCES.txt +0 -1
- {google_auth-2.45.0 → google_auth-2.46.0}/google_auth.egg-info/requires.txt +0 -1
- {google_auth-2.45.0 → google_auth-2.46.0}/setup.cfg +0 -3
- {google_auth-2.45.0 → google_auth-2.46.0}/setup.py +0 -1
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/compute_engine/test__metadata.py +3 -3
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/compute_engine/test__mtls.py +1 -1
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/compute_engine/test_credentials.py +1 -1
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/conftest.py +1 -1
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/crypt/test__cryptography_rsa.py +1 -1
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/crypt/test__python_rsa.py +2 -2
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/crypt/test_es.py +1 -1
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/crypt/test_es256.py +1 -1
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/oauth2/test__client.py +1 -1
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/oauth2/test_challenges.py +1 -2
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/oauth2/test_credentials.py +26 -1
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/oauth2/test_gdch_credentials.py +1 -1
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/oauth2/test_id_token.py +1 -1
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/oauth2/test_reauth.py +1 -1
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/oauth2/test_service_account.py +1 -1
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/oauth2/test_sts.py +3 -4
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/oauth2/test_webauthn_handler.py +1 -1
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/oauth2/test_webauthn_handler_factory.py +2 -1
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/oauth2/test_webauthn_types.py +3 -3
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/test__cloud_sdk.py +1 -1
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/test__default.py +6 -4
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/test__exponential_backoff.py +4 -3
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/test__oauth2client.py +2 -3
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/test__refresh_worker.py +1 -1
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/test_agent_identity_utils.py +1 -1
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/test_app_engine.py +1 -1
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/test_aws.py +5 -3
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/test_credentials.py +3 -2
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/test_downscoped.py +3 -4
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/test_external_account.py +3 -3
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/test_external_account_authorized_user.py +11 -9
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/test_iam.py +1 -1
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/test_identity_pool.py +7 -8
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/test_impersonated_credentials.py +41 -12
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/test_jwt.py +5 -5
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/test_metrics.py +1 -2
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/test_pluggable.py +6 -5
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/transport/aio/test_aiohttp.py +1 -1
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/transport/aio/test_sessions.py +1 -1
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/transport/test__custom_tls_signer.py +7 -3
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/transport/test__mtls_helper.py +71 -75
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/transport/test_grpc.py +1 -1
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/transport/test_mtls.py +83 -15
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/transport/test_requests.py +1 -1
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/transport/test_urllib3.py +1 -1
- {google_auth-2.45.0 → google_auth-2.46.0}/LICENSE +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/MANIFEST.in +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/README.rst +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/google/auth/__init__.py +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/google/auth/_agent_identity_utils.py +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/google/auth/_constants.py +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/google/auth/_credentials_async.py +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/google/auth/_credentials_base.py +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/google/auth/_default_async.py +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/google/auth/_exponential_backoff.py +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/google/auth/_helpers.py +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/google/auth/_jwt_async.py +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/google/auth/_oauth2client.py +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/google/auth/_service_account_info.py +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/google/auth/aio/__init__.py +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/google/auth/aio/_helpers.py +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/google/auth/aio/credentials.py +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/google/auth/aio/transport/__init__.py +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/google/auth/api_key.py +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/google/auth/app_engine.py +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/google/auth/compute_engine/__init__.py +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/google/auth/compute_engine/_mtls.py +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/google/auth/crypt/__init__.py +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/google/auth/crypt/_cryptography_rsa.py +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/google/auth/crypt/_helpers.py +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/google/auth/crypt/_python_rsa.py +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/google/auth/crypt/base.py +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/google/auth/crypt/es.py +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/google/auth/crypt/es256.py +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/google/auth/crypt/rsa.py +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/google/auth/downscoped.py +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/google/auth/environment_vars.py +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/google/auth/exceptions.py +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/google/auth/iam.py +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/google/auth/py.typed +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/google/auth/transport/__init__.py +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/google/auth/transport/_custom_tls_signer.py +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/google/auth/transport/_mtls_helper.py +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/google/auth/transport/_requests_base.py +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/google/oauth2/__init__.py +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/google/oauth2/_credentials_async.py +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/google/oauth2/_service_account_async.py +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/google/oauth2/challenges.py +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/google/oauth2/gdch_credentials.py +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/google/oauth2/py.typed +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/google/oauth2/sts.py +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/google/oauth2/utils.py +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/google/oauth2/webauthn_handler_factory.py +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/google/oauth2/webauthn_types.py +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/google_auth.egg-info/dependency_links.txt +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/google_auth.egg-info/top_level.txt +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/__init__.py +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/aio/test__helpers.py +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/compute_engine/__init__.py +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/compute_engine/data/smbios_product_name +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/compute_engine/data/smbios_product_name_non_google +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/crypt/__init__.py +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/crypt/test_crypt.py +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/data/authorized_user.json +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/data/authorized_user_cloud_sdk.json +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/data/authorized_user_cloud_sdk_with_quota_project_id.json +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/data/authorized_user_with_rapt_token.json +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/data/client_secrets.json +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/data/context_aware_metadata.json +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/data/enterprise_cert_invalid.json +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/data/enterprise_cert_valid.json +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/data/enterprise_cert_valid_provider.json +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/data/es256_privatekey.pem +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/data/es256_public_cert.pem +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/data/es256_publickey.pem +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/data/es256_service_account.json +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/data/es384_privatekey.pem +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/data/es384_public_cert.pem +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/data/es384_publickey.pem +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/data/es384_service_account.json +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/data/external_account_authorized_user.json +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/data/external_account_authorized_user_non_gdu.json +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/data/external_subject_token.json +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/data/external_subject_token.txt +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/data/gdch_service_account.json +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/data/impersonated_service_account_authorized_user_source.json +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/data/impersonated_service_account_external_account_authorized_user_source.json +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/data/impersonated_service_account_service_account_source.json +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/data/impersonated_service_account_with_quota_project.json +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/data/old_oauth_credentials_py3.pickle +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/data/other_cert.pem +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/data/pem_from_pkcs12.pem +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/data/privatekey.p12 +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/data/privatekey.pem +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/data/privatekey.pub +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/data/public_cert.pem +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/data/service_account.json +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/data/service_account_non_gdu.json +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/data/trust_chain_with_leaf.pem +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/data/trust_chain_without_leaf.pem +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/data/trust_chain_wrong_order.pem +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/oauth2/__init__.py +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/oauth2/test_utils.py +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/test__helpers.py +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/test__service_account_info.py +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/test_api_key.py +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/test_credentials_async.py +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/test_exceptions.py +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/test_packaging.py +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/transport/__init__.py +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/transport/compliance.py +0 -0
- {google_auth-2.45.0 → google_auth-2.46.0}/tests/transport/test__http_client.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: google-auth
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.46.0
|
|
4
4
|
Summary: Google Authentication Library
|
|
5
5
|
Home-page: https://github.com/googleapis/google-auth-library-python
|
|
6
6
|
Author: Google Cloud Platform
|
|
@@ -54,7 +54,6 @@ Provides-Extra: testing
|
|
|
54
54
|
Requires-Dist: grpcio; extra == "testing"
|
|
55
55
|
Requires-Dist: flask; extra == "testing"
|
|
56
56
|
Requires-Dist: freezegun; extra == "testing"
|
|
57
|
-
Requires-Dist: mock; extra == "testing"
|
|
58
57
|
Requires-Dist: oauth2client; extra == "testing"
|
|
59
58
|
Requires-Dist: pyjwt>=2.0; extra == "testing"
|
|
60
59
|
Requires-Dist: cryptography>=38.0.3; extra == "testing"
|
|
@@ -83,7 +83,7 @@ def get_application_default_credentials_path():
|
|
|
83
83
|
|
|
84
84
|
|
|
85
85
|
def _run_subprocess_ignore_stderr(command):
|
|
86
|
-
"""
|
|
86
|
+
"""Return subprocess.check_output with the given command and ignores stderr."""
|
|
87
87
|
with open(os.devnull, "w") as devnull:
|
|
88
88
|
output = subprocess.check_output(command, stderr=devnull)
|
|
89
89
|
return output
|
|
@@ -17,16 +17,22 @@
|
|
|
17
17
|
Implements application default credentials and project ID detection.
|
|
18
18
|
"""
|
|
19
19
|
|
|
20
|
+
from collections.abc import Sequence
|
|
20
21
|
import io
|
|
21
22
|
import json
|
|
22
23
|
import logging
|
|
23
24
|
import os
|
|
25
|
+
from typing import Optional, TYPE_CHECKING
|
|
24
26
|
import warnings
|
|
25
27
|
|
|
26
28
|
from google.auth import environment_vars
|
|
27
29
|
from google.auth import exceptions
|
|
28
30
|
import google.auth.transport._http_client
|
|
29
31
|
|
|
32
|
+
if TYPE_CHECKING: # pragma: NO COVER
|
|
33
|
+
from google.auth.credentials import Credentials # noqa: F401
|
|
34
|
+
from google.auth.transport import Request # noqa: F401
|
|
35
|
+
|
|
30
36
|
_LOGGER = logging.getLogger(__name__)
|
|
31
37
|
|
|
32
38
|
# Valid types accepted for file-based credentials.
|
|
@@ -538,8 +544,10 @@ def _get_impersonated_service_account_credentials(filename, info, scopes):
|
|
|
538
544
|
from google.auth import impersonated_credentials
|
|
539
545
|
|
|
540
546
|
try:
|
|
541
|
-
credentials =
|
|
542
|
-
|
|
547
|
+
credentials = (
|
|
548
|
+
impersonated_credentials.Credentials.from_impersonated_service_account_info(
|
|
549
|
+
info, scopes=scopes
|
|
550
|
+
)
|
|
543
551
|
)
|
|
544
552
|
except ValueError as caught_exc:
|
|
545
553
|
msg = "Failed to load impersonated service account credentials from {}".format(
|
|
@@ -554,8 +562,8 @@ def _get_gdch_service_account_credentials(filename, info):
|
|
|
554
562
|
from google.oauth2 import gdch_credentials
|
|
555
563
|
|
|
556
564
|
try:
|
|
557
|
-
credentials =
|
|
558
|
-
info
|
|
565
|
+
credentials = (
|
|
566
|
+
gdch_credentials.ServiceAccountCredentials.from_service_account_info(info)
|
|
559
567
|
)
|
|
560
568
|
except ValueError as caught_exc:
|
|
561
569
|
msg = "Failed to load GDCH service account credentials from {}".format(filename)
|
|
@@ -586,7 +594,12 @@ def _apply_quota_project_id(credentials, quota_project_id):
|
|
|
586
594
|
return credentials
|
|
587
595
|
|
|
588
596
|
|
|
589
|
-
def default(
|
|
597
|
+
def default(
|
|
598
|
+
scopes: Optional[Sequence[str]] = None,
|
|
599
|
+
request: Optional["google.auth.transport.Request"] = None,
|
|
600
|
+
quota_project_id: Optional[str] = None,
|
|
601
|
+
default_scopes: Optional[Sequence[str]] = None,
|
|
602
|
+
) -> tuple["google.auth.credentials.Credentials", Optional[str]]:
|
|
590
603
|
"""Gets the default credentials for the current environment.
|
|
591
604
|
|
|
592
605
|
`Application Default Credentials`_ provides an easy way to obtain
|
|
@@ -61,8 +61,8 @@ class RefreshThreadManager:
|
|
|
61
61
|
|
|
62
62
|
def clear_error(self):
|
|
63
63
|
"""
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
Removes any errors that were stored from previous background refreshes.
|
|
65
|
+
"""
|
|
66
66
|
with self._lock:
|
|
67
67
|
if self._worker:
|
|
68
68
|
self._worker._error_info = None
|
|
@@ -104,7 +104,7 @@ class Request(transport.Request):
|
|
|
104
104
|
# Custom aiohttp Session Example:
|
|
105
105
|
session = session=aiohttp.ClientSession(auto_decompress=False)
|
|
106
106
|
request = google.auth.aio.transport.aiohttp.Request(session=session)
|
|
107
|
-
|
|
107
|
+
auth_session = google.auth.aio.transport.sessions.AsyncAuthorizedSession(auth_request=request)
|
|
108
108
|
|
|
109
109
|
Args:
|
|
110
110
|
session (aiohttp.ClientSession): An instance :class:`aiohttp.ClientSession` used
|
|
@@ -159,7 +159,7 @@ class AsyncAuthorizedSession:
|
|
|
159
159
|
at ``max_allowed_time``. It might take longer, for example, if
|
|
160
160
|
an underlying request takes a lot of time, but the request
|
|
161
161
|
itself does not timeout, e.g. if a large file is being
|
|
162
|
-
transmitted. The
|
|
162
|
+
transmitted. The timeout error will be raised after such
|
|
163
163
|
request completes.
|
|
164
164
|
|
|
165
165
|
Returns:
|
|
@@ -348,10 +348,10 @@ def _generate_authentication_header_map(
|
|
|
348
348
|
class AwsSecurityCredentials:
|
|
349
349
|
"""A class that models AWS security credentials with an optional session token.
|
|
350
350
|
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
351
|
+
Attributes:
|
|
352
|
+
access_key_id (str): The AWS security credentials access key id.
|
|
353
|
+
secret_access_key (str): The AWS security credentials secret access key.
|
|
354
|
+
session_token (Optional[str]): The optional AWS security credentials session token. This should be set when using temporary credentials.
|
|
355
355
|
"""
|
|
356
356
|
|
|
357
357
|
access_key_id: str
|
|
@@ -420,7 +420,6 @@ class _DefaultAwsSecurityCredentialsSupplier(AwsSecurityCredentialsSupplier):
|
|
|
420
420
|
|
|
421
421
|
@_helpers.copy_docstring(AwsSecurityCredentialsSupplier)
|
|
422
422
|
def get_aws_security_credentials(self, context, request):
|
|
423
|
-
|
|
424
423
|
# Check environment variables for permanent credentials first.
|
|
425
424
|
# https://docs.aws.amazon.com/general/latest/gr/aws-sec-cred-types.html
|
|
426
425
|
env_aws_access_key_id = os.environ.get(environment_vars.AWS_ACCESS_KEY_ID)
|
|
@@ -688,8 +687,8 @@ class Credentials(external_account.Credentials):
|
|
|
688
687
|
)
|
|
689
688
|
else:
|
|
690
689
|
environment_id = credential_source.get("environment_id") or ""
|
|
691
|
-
self._aws_security_credentials_supplier =
|
|
692
|
-
credential_source
|
|
690
|
+
self._aws_security_credentials_supplier = (
|
|
691
|
+
_DefaultAwsSecurityCredentialsSupplier(credential_source)
|
|
693
692
|
)
|
|
694
693
|
self._cred_verification_url = credential_source.get(
|
|
695
694
|
"regional_cred_verification_url"
|
|
@@ -759,8 +758,10 @@ class Credentials(external_account.Credentials):
|
|
|
759
758
|
|
|
760
759
|
# Retrieve the AWS security credentials needed to generate the signed
|
|
761
760
|
# request.
|
|
762
|
-
aws_security_credentials =
|
|
763
|
-
self.
|
|
761
|
+
aws_security_credentials = (
|
|
762
|
+
self._aws_security_credentials_supplier.get_aws_security_credentials(
|
|
763
|
+
self._supplier_context, request
|
|
764
|
+
)
|
|
764
765
|
)
|
|
765
766
|
# Generate the signed request to AWS STS GetCallerIdentity API.
|
|
766
767
|
# Use the required regional endpoint. Otherwise, the request will fail.
|
|
@@ -294,7 +294,7 @@ def get(
|
|
|
294
294
|
url = _helpers.update_query(base_url, query_params)
|
|
295
295
|
|
|
296
296
|
backoff = ExponentialBackoff(total_attempts=retry_count)
|
|
297
|
-
|
|
297
|
+
last_exception = None
|
|
298
298
|
for attempt in backoff:
|
|
299
299
|
try:
|
|
300
300
|
response = request(
|
|
@@ -308,13 +308,10 @@ def get(
|
|
|
308
308
|
retry_count,
|
|
309
309
|
response.status,
|
|
310
310
|
)
|
|
311
|
-
|
|
312
|
-
response.data.decode("utf-8")
|
|
313
|
-
if hasattr(response.data, "decode")
|
|
314
|
-
else response.data
|
|
315
|
-
)
|
|
311
|
+
last_exception = None
|
|
316
312
|
continue
|
|
317
313
|
else:
|
|
314
|
+
last_exception = None
|
|
318
315
|
break
|
|
319
316
|
|
|
320
317
|
except exceptions.TransportError as e:
|
|
@@ -325,14 +322,27 @@ def get(
|
|
|
325
322
|
retry_count,
|
|
326
323
|
e,
|
|
327
324
|
)
|
|
328
|
-
|
|
325
|
+
last_exception = e
|
|
329
326
|
else:
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
327
|
+
if last_exception:
|
|
328
|
+
raise exceptions.TransportError(
|
|
329
|
+
"Failed to retrieve {} from the Google Compute Engine "
|
|
330
|
+
"metadata service. Compute Engine Metadata server unavailable. "
|
|
331
|
+
"Last exception: {}".format(url, last_exception)
|
|
332
|
+
) from last_exception
|
|
333
|
+
else:
|
|
334
|
+
error_details = (
|
|
335
|
+
response.data.decode("utf-8")
|
|
336
|
+
if hasattr(response.data, "decode")
|
|
337
|
+
else response.data
|
|
338
|
+
)
|
|
339
|
+
raise exceptions.TransportError(
|
|
340
|
+
"Failed to retrieve {} from the Google Compute Engine "
|
|
341
|
+
"metadata service. Compute Engine Metadata server unavailable. "
|
|
342
|
+
"Response status: {}\nResponse details:\n{}".format(
|
|
343
|
+
url, response.status, error_details
|
|
344
|
+
)
|
|
334
345
|
)
|
|
335
|
-
)
|
|
336
346
|
|
|
337
347
|
content = _helpers.from_bytes(response.data)
|
|
338
348
|
|
|
@@ -123,7 +123,7 @@ class Credentials(
|
|
|
123
123
|
def _metric_header_for_usage(self):
|
|
124
124
|
return metrics.CRED_TYPE_SA_MDS
|
|
125
125
|
|
|
126
|
-
def
|
|
126
|
+
def _perform_refresh_token(self, request):
|
|
127
127
|
"""Refresh the access token and scopes.
|
|
128
128
|
|
|
129
129
|
Args:
|
|
@@ -399,7 +399,6 @@ class IDTokenCredentials(
|
|
|
399
399
|
|
|
400
400
|
@_helpers.copy_docstring(credentials.CredentialsWithQuotaProject)
|
|
401
401
|
def with_quota_project(self, quota_project_id):
|
|
402
|
-
|
|
403
402
|
# since the signer is already instantiated,
|
|
404
403
|
# the request is not needed
|
|
405
404
|
if self._use_metadata_identity_endpoint:
|
|
@@ -423,7 +422,6 @@ class IDTokenCredentials(
|
|
|
423
422
|
|
|
424
423
|
@_helpers.copy_docstring(credentials.CredentialsWithTokenUri)
|
|
425
424
|
def with_token_uri(self, token_uri):
|
|
426
|
-
|
|
427
425
|
# since the signer is already instantiated,
|
|
428
426
|
# the request is not needed
|
|
429
427
|
if self._use_metadata_identity_endpoint:
|
|
@@ -292,7 +292,7 @@ class CredentialsWithTrustBoundary(Credentials):
|
|
|
292
292
|
"""Abstract base for credentials supporting ``with_trust_boundary`` factory"""
|
|
293
293
|
|
|
294
294
|
@abc.abstractmethod
|
|
295
|
-
def
|
|
295
|
+
def _perform_refresh_token(self, request):
|
|
296
296
|
"""Refreshes the access token.
|
|
297
297
|
|
|
298
298
|
Args:
|
|
@@ -303,7 +303,7 @@ class CredentialsWithTrustBoundary(Credentials):
|
|
|
303
303
|
google.auth.exceptions.RefreshError: If the credentials could
|
|
304
304
|
not be refreshed.
|
|
305
305
|
"""
|
|
306
|
-
raise NotImplementedError("
|
|
306
|
+
raise NotImplementedError("_perform_refresh_token must be implemented")
|
|
307
307
|
|
|
308
308
|
def with_trust_boundary(self, trust_boundary):
|
|
309
309
|
"""Returns a copy of these credentials with a modified trust boundary.
|
|
@@ -362,7 +362,7 @@ class CredentialsWithTrustBoundary(Credentials):
|
|
|
362
362
|
This method calls the subclass's token refresh logic and then
|
|
363
363
|
refreshes the trust boundary if applicable.
|
|
364
364
|
"""
|
|
365
|
-
self.
|
|
365
|
+
self._perform_refresh_token(request)
|
|
366
366
|
self._refresh_trust_boundary(request)
|
|
367
367
|
|
|
368
368
|
def _refresh_trust_boundary(self, request):
|
|
@@ -98,7 +98,8 @@ class Credentials(
|
|
|
98
98
|
is used.
|
|
99
99
|
When the credential configuration is accepted from an
|
|
100
100
|
untrusted source, you should validate it before using.
|
|
101
|
-
Refer https://cloud.google.com/docs/authentication/external/externally-sourced-credentials for more details.
|
|
101
|
+
Refer https://cloud.google.com/docs/authentication/external/externally-sourced-credentials for more details.
|
|
102
|
+
"""
|
|
102
103
|
|
|
103
104
|
def __init__(
|
|
104
105
|
self,
|
|
@@ -419,7 +420,7 @@ class Credentials(
|
|
|
419
420
|
source credentials and the impersonated credentials. For non-impersonated
|
|
420
421
|
credentials, it will refresh the access token and the trust boundary.
|
|
421
422
|
"""
|
|
422
|
-
self.
|
|
423
|
+
self._perform_refresh_token(request)
|
|
423
424
|
self._handle_trust_boundary(request)
|
|
424
425
|
|
|
425
426
|
def _handle_trust_boundary(self, request):
|
|
@@ -431,7 +432,7 @@ class Credentials(
|
|
|
431
432
|
# Otherwise, refresh the trust boundary for the external account.
|
|
432
433
|
self._refresh_trust_boundary(request)
|
|
433
434
|
|
|
434
|
-
def
|
|
435
|
+
def _perform_refresh_token(self, request, cert_fingerprint=None):
|
|
435
436
|
scopes = self._scopes if self._scopes is not None else self._default_scopes
|
|
436
437
|
|
|
437
438
|
# Inject client certificate into request.
|
|
@@ -70,7 +70,8 @@ class Credentials(
|
|
|
70
70
|
is used.
|
|
71
71
|
When the credential configuration is accepted from an
|
|
72
72
|
untrusted source, you should validate it before using.
|
|
73
|
-
Refer https://cloud.google.com/docs/authentication/external/externally-sourced-credentials for more details.
|
|
73
|
+
Refer https://cloud.google.com/docs/authentication/external/externally-sourced-credentials for more details.
|
|
74
|
+
"""
|
|
74
75
|
|
|
75
76
|
def __init__(
|
|
76
77
|
self,
|
|
@@ -123,7 +124,7 @@ class Credentials(
|
|
|
123
124
|
self.token = token
|
|
124
125
|
self.expiry = expiry
|
|
125
126
|
self._audience = audience
|
|
126
|
-
self.
|
|
127
|
+
self._refresh_token = refresh_token
|
|
127
128
|
self._token_url = token_url
|
|
128
129
|
self._token_info_url = token_info_url
|
|
129
130
|
self._client_id = client_id
|
|
@@ -170,7 +171,7 @@ class Credentials(
|
|
|
170
171
|
def constructor_args(self):
|
|
171
172
|
return {
|
|
172
173
|
"audience": self._audience,
|
|
173
|
-
"refresh_token": self.
|
|
174
|
+
"refresh_token": self._refresh_token,
|
|
174
175
|
"token_url": self._token_url,
|
|
175
176
|
"token_info_url": self._token_info_url,
|
|
176
177
|
"client_id": self._client_id,
|
|
@@ -214,7 +215,7 @@ class Credentials(
|
|
|
214
215
|
@property
|
|
215
216
|
def refresh_token(self):
|
|
216
217
|
"""Optional[str]: The OAuth 2.0 refresh token."""
|
|
217
|
-
return self.
|
|
218
|
+
return self._refresh_token
|
|
218
219
|
|
|
219
220
|
@property
|
|
220
221
|
def token_url(self):
|
|
@@ -240,7 +241,7 @@ class Credentials(
|
|
|
240
241
|
def can_refresh(self):
|
|
241
242
|
return all(
|
|
242
243
|
(
|
|
243
|
-
self.
|
|
244
|
+
self._refresh_token,
|
|
244
245
|
self._token_url,
|
|
245
246
|
self._client_id,
|
|
246
247
|
self._client_secret,
|
|
@@ -278,7 +279,7 @@ class Credentials(
|
|
|
278
279
|
strip = strip if strip else []
|
|
279
280
|
return json.dumps({k: v for (k, v) in self.info.items() if k not in strip})
|
|
280
281
|
|
|
281
|
-
def
|
|
282
|
+
def _perform_refresh_token(self, request):
|
|
282
283
|
"""Refreshes the access token.
|
|
283
284
|
|
|
284
285
|
Args:
|
|
@@ -297,7 +298,7 @@ class Credentials(
|
|
|
297
298
|
)
|
|
298
299
|
|
|
299
300
|
now = _helpers.utcnow()
|
|
300
|
-
response_data = self._sts_client.refresh_token(request, self.
|
|
301
|
+
response_data = self._sts_client.refresh_token(request, self._refresh_token)
|
|
301
302
|
|
|
302
303
|
self.token = response_data.get("access_token")
|
|
303
304
|
|
|
@@ -305,7 +306,7 @@ class Credentials(
|
|
|
305
306
|
self.expiry = now + lifetime
|
|
306
307
|
|
|
307
308
|
if "refresh_token" in response_data:
|
|
308
|
-
self.
|
|
309
|
+
self._refresh_token = response_data["refresh_token"]
|
|
309
310
|
|
|
310
311
|
def _build_trust_boundary_lookup_url(self):
|
|
311
312
|
"""Builds and returns the URL for the trust boundary lookup API."""
|
|
@@ -332,7 +333,7 @@ class Credentials(
|
|
|
332
333
|
google.auth.exceptions.OAuthError: If the token could not be
|
|
333
334
|
revoked.
|
|
334
335
|
"""
|
|
335
|
-
if not self._revoke_url or not self.
|
|
336
|
+
if not self._revoke_url or not self._refresh_token:
|
|
336
337
|
raise exceptions.OAuthError(
|
|
337
338
|
"The credentials do not contain the necessary fields to "
|
|
338
339
|
"revoke the refresh token. You must specify revoke_url and "
|
|
@@ -340,7 +341,7 @@ class Credentials(
|
|
|
340
341
|
)
|
|
341
342
|
|
|
342
343
|
self._sts_client.revoke_token(
|
|
343
|
-
request, self.
|
|
344
|
+
request, self._refresh_token, "refresh_token", self._revoke_url
|
|
344
345
|
)
|
|
345
346
|
self.token = None
|
|
346
347
|
self._refresh_token = None
|
|
@@ -83,9 +83,9 @@ class SubjectTokenSupplier(metaclass=abc.ABCMeta):
|
|
|
83
83
|
|
|
84
84
|
class _TokenContent(NamedTuple):
|
|
85
85
|
"""Models the token content response from file and url internal suppliers.
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
86
|
+
Attributes:
|
|
87
|
+
content (str): The string content of the file or URL response.
|
|
88
|
+
location (str): The location the content was retrieved from. This will either be a file location or a URL.
|
|
89
89
|
"""
|
|
90
90
|
|
|
91
91
|
content: str
|
|
@@ -93,7 +93,7 @@ class _TokenContent(NamedTuple):
|
|
|
93
93
|
|
|
94
94
|
|
|
95
95
|
class _FileSupplier(SubjectTokenSupplier):
|
|
96
|
-
"""
|
|
96
|
+
"""Internal implementation of subject token supplier which supports reading a subject token from a file."""
|
|
97
97
|
|
|
98
98
|
def __init__(self, path, format_type, subject_token_field_name):
|
|
99
99
|
self._path = path
|
|
@@ -114,7 +114,7 @@ class _FileSupplier(SubjectTokenSupplier):
|
|
|
114
114
|
|
|
115
115
|
|
|
116
116
|
class _UrlSupplier(SubjectTokenSupplier):
|
|
117
|
-
"""
|
|
117
|
+
"""Internal implementation of subject token supplier which supports retrieving a subject token by calling a URL endpoint."""
|
|
118
118
|
|
|
119
119
|
def __init__(self, url, format_type, subject_token_field_name, headers):
|
|
120
120
|
self._url = url
|
|
@@ -261,7 +261,8 @@ class Credentials(external_account.Credentials):
|
|
|
261
261
|
is used.
|
|
262
262
|
When the credential configuration is accepted from an
|
|
263
263
|
untrusted source, you should validate it before using.
|
|
264
|
-
Refer https://cloud.google.com/docs/authentication/external/externally-sourced-credentials for more details.
|
|
264
|
+
Refer https://cloud.google.com/docs/authentication/external/externally-sourced-credentials for more details.
|
|
265
|
+
"""
|
|
265
266
|
|
|
266
267
|
def __init__(
|
|
267
268
|
self,
|
|
@@ -566,9 +567,9 @@ class Credentials(external_account.Credentials):
|
|
|
566
567
|
cert_bytes = self._get_cert_bytes()
|
|
567
568
|
cert = _agent_identity_utils.parse_certificate(cert_bytes)
|
|
568
569
|
if _agent_identity_utils.should_request_bound_token(cert):
|
|
569
|
-
cert_fingerprint =
|
|
570
|
-
cert
|
|
570
|
+
cert_fingerprint = (
|
|
571
|
+
_agent_identity_utils.calculate_certificate_fingerprint(cert)
|
|
571
572
|
)
|
|
572
573
|
|
|
573
|
-
self.
|
|
574
|
+
self._perform_refresh_token(request, cert_fingerprint=cert_fingerprint)
|
|
574
575
|
self._handle_trust_boundary(request)
|
|
@@ -272,7 +272,7 @@ class Credentials(
|
|
|
272
272
|
def _metric_header_for_usage(self):
|
|
273
273
|
return metrics.CRED_TYPE_SA_IMPERSONATE
|
|
274
274
|
|
|
275
|
-
def
|
|
275
|
+
def _perform_refresh_token(self, request):
|
|
276
276
|
"""Updates credentials with a new access_token representing
|
|
277
277
|
the impersonated account.
|
|
278
278
|
|
|
@@ -640,7 +640,14 @@ class IDTokenCredentials(credentials.CredentialsWithQuotaProject):
|
|
|
640
640
|
"Error getting ID token: {}".format(response.json())
|
|
641
641
|
)
|
|
642
642
|
|
|
643
|
-
|
|
643
|
+
try:
|
|
644
|
+
id_token = response.json()["token"]
|
|
645
|
+
except (KeyError, ValueError) as caught_exc:
|
|
646
|
+
new_exc = exceptions.RefreshError(
|
|
647
|
+
"No ID token in response.", response.json()
|
|
648
|
+
)
|
|
649
|
+
raise new_exc from caught_exc
|
|
650
|
+
|
|
644
651
|
self.token = id_token
|
|
645
652
|
self.expiry = datetime.utcfromtimestamp(
|
|
646
653
|
jwt.decode(id_token, verify=False)["exp"]
|
|
@@ -586,7 +586,7 @@ class Credentials(
|
|
|
586
586
|
|
|
587
587
|
@property # type: ignore
|
|
588
588
|
def additional_claims(self):
|
|
589
|
-
"""
|
|
589
|
+
"""Additional claims the JWT object was created with."""
|
|
590
590
|
return self._additional_claims
|
|
591
591
|
|
|
592
592
|
|
|
@@ -760,7 +760,6 @@ class OnDemandCredentials(
|
|
|
760
760
|
|
|
761
761
|
@_helpers.copy_docstring(google.auth.credentials.CredentialsWithQuotaProject)
|
|
762
762
|
def with_quota_project(self, quota_project_id):
|
|
763
|
-
|
|
764
763
|
return self.__class__(
|
|
765
764
|
self._signer,
|
|
766
765
|
issuer=self._issuer,
|
|
@@ -48,6 +48,7 @@ def python_and_auth_lib_version():
|
|
|
48
48
|
|
|
49
49
|
# Token request metric header values
|
|
50
50
|
|
|
51
|
+
|
|
51
52
|
# x-goog-api-client header value for access token request via metadata server.
|
|
52
53
|
# Example: "gl-python/3.7 auth/1.1 auth-request-type/at cred-type/mds"
|
|
53
54
|
def token_request_access_token_mds():
|
|
@@ -108,6 +109,7 @@ def token_request_user():
|
|
|
108
109
|
|
|
109
110
|
# Miscellenous metrics
|
|
110
111
|
|
|
112
|
+
|
|
111
113
|
# x-goog-api-client header value for metadata server ping.
|
|
112
114
|
# Example: "gl-python/3.7 auth/1.1 auth-request-type/mds"
|
|
113
115
|
def mds_ping():
|
|
@@ -66,7 +66,8 @@ class Credentials(external_account.Credentials):
|
|
|
66
66
|
is used.
|
|
67
67
|
When the credential configuration is accepted from an
|
|
68
68
|
untrusted source, you should validate it before using.
|
|
69
|
-
Refer https://cloud.google.com/docs/authentication/external/externally-sourced-credentials for more details.
|
|
69
|
+
Refer https://cloud.google.com/docs/authentication/external/externally-sourced-credentials for more details.
|
|
70
|
+
"""
|
|
70
71
|
|
|
71
72
|
def __init__(
|
|
72
73
|
self,
|
|
@@ -129,17 +130,17 @@ class Credentials(external_account.Credentials):
|
|
|
129
130
|
raise exceptions.MalformedError(
|
|
130
131
|
"Missing credential_source. An 'executable' must be provided."
|
|
131
132
|
)
|
|
132
|
-
self._credential_source_executable_command =
|
|
133
|
-
"command"
|
|
133
|
+
self._credential_source_executable_command = (
|
|
134
|
+
self._credential_source_executable.get("command")
|
|
134
135
|
)
|
|
135
|
-
self._credential_source_executable_timeout_millis =
|
|
136
|
-
"timeout_millis"
|
|
136
|
+
self._credential_source_executable_timeout_millis = (
|
|
137
|
+
self._credential_source_executable.get("timeout_millis")
|
|
137
138
|
)
|
|
138
|
-
self._credential_source_executable_interactive_timeout_millis =
|
|
139
|
-
"interactive_timeout_millis"
|
|
139
|
+
self._credential_source_executable_interactive_timeout_millis = (
|
|
140
|
+
self._credential_source_executable.get("interactive_timeout_millis")
|
|
140
141
|
)
|
|
141
|
-
self._credential_source_executable_output_file =
|
|
142
|
-
"output_file"
|
|
142
|
+
self._credential_source_executable_output_file = (
|
|
143
|
+
self._credential_source_executable.get("output_file")
|
|
143
144
|
)
|
|
144
145
|
|
|
145
146
|
# Dummy value. This variable is only used via injection, not exposed to ctor
|
|
@@ -276,7 +276,6 @@ class AuthorizedSession(aiohttp.ClientSession):
|
|
|
276
276
|
auto_decompress=False,
|
|
277
277
|
**kwargs,
|
|
278
278
|
):
|
|
279
|
-
|
|
280
279
|
"""Implementation of Authorized Session aiohttp request.
|
|
281
280
|
|
|
282
281
|
Args:
|
|
@@ -302,7 +301,7 @@ class AuthorizedSession(aiohttp.ClientSession):
|
|
|
302
301
|
at ``max_allowed_time``. It might take longer, for example, if
|
|
303
302
|
an underlying request takes a lot of time, but the request
|
|
304
303
|
itself does not timeout, e.g. if a large file is being
|
|
305
|
-
transmitted. The
|
|
304
|
+
transmitted. The timeout error will be raised after such
|
|
306
305
|
request completes.
|
|
307
306
|
"""
|
|
308
307
|
# Headers come in as bytes which isn't expected behavior, the resumable
|
|
@@ -358,7 +357,6 @@ class AuthorizedSession(aiohttp.ClientSession):
|
|
|
358
357
|
response.status in self._refresh_status_codes
|
|
359
358
|
and _credential_refresh_attempt < self._max_refresh_attempts
|
|
360
359
|
):
|
|
361
|
-
|
|
362
360
|
requests._LOGGER.info(
|
|
363
361
|
"Refreshing credentials due to a %s response. Attempt %s/%s.",
|
|
364
362
|
response.status,
|
|
@@ -100,7 +100,6 @@ class Request(transport.Request):
|
|
|
100
100
|
connection = http_client.HTTPConnection(parts.netloc, timeout=timeout)
|
|
101
101
|
|
|
102
102
|
try:
|
|
103
|
-
|
|
104
103
|
_helpers.request_log(_LOGGER, method, url, body, headers)
|
|
105
104
|
connection.request(method, path, body=body, headers=headers, **kwargs)
|
|
106
105
|
response = connection.getresponse()
|
|
@@ -146,7 +146,7 @@ def secure_authorized_channel(
|
|
|
146
146
|
regular_ssl_credentials = grpc.ssl_channel_credentials()
|
|
147
147
|
|
|
148
148
|
channel = google.auth.transport.grpc.secure_authorized_channel(
|
|
149
|
-
credentials,
|
|
149
|
+
credentials, request, regular_endpoint,
|
|
150
150
|
ssl_credentials=regular_ssl_credentials)
|
|
151
151
|
|
|
152
152
|
Option 2: create a mutual TLS channel by calling a callback which returns
|
|
@@ -162,7 +162,7 @@ def secure_authorized_channel(
|
|
|
162
162
|
|
|
163
163
|
try:
|
|
164
164
|
channel = google.auth.transport.grpc.secure_authorized_channel(
|
|
165
|
-
credentials,
|
|
165
|
+
credentials, request, mtls_endpoint,
|
|
166
166
|
client_cert_callback=my_client_cert_callback)
|
|
167
167
|
except MyClientCertFailureException:
|
|
168
168
|
# handle the exception
|
|
@@ -186,7 +186,7 @@ def secure_authorized_channel(
|
|
|
186
186
|
else:
|
|
187
187
|
endpoint_to_use = regular_endpoint
|
|
188
188
|
channel = google.auth.transport.grpc.secure_authorized_channel(
|
|
189
|
-
credentials,
|
|
189
|
+
credentials, request, endpoint_to_use,
|
|
190
190
|
ssl_credentials=default_ssl_credentials)
|
|
191
191
|
|
|
192
192
|
Option 4: not setting ssl_credentials and client_cert_callback. For devices
|
|
@@ -200,14 +200,14 @@ def secure_authorized_channel(
|
|
|
200
200
|
certificate and key::
|
|
201
201
|
|
|
202
202
|
channel = google.auth.transport.grpc.secure_authorized_channel(
|
|
203
|
-
credentials,
|
|
203
|
+
credentials, request, regular_endpoint)
|
|
204
204
|
|
|
205
205
|
The following code uses mtls_endpoint, if the created channle is regular,
|
|
206
206
|
and API mtls_endpoint is confgured to require client SSL credentials, API
|
|
207
207
|
calls using this channel will be rejected::
|
|
208
208
|
|
|
209
209
|
channel = google.auth.transport.grpc.secure_authorized_channel(
|
|
210
|
-
credentials,
|
|
210
|
+
credentials, request, mtls_endpoint)
|
|
211
211
|
|
|
212
212
|
Args:
|
|
213
213
|
credentials (google.auth.credentials.Credentials): The credentials to
|
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
|
|
15
15
|
"""Utilites for mutual TLS."""
|
|
16
16
|
|
|
17
|
+
from os import getenv
|
|
18
|
+
|
|
17
19
|
from google.auth import exceptions
|
|
18
20
|
from google.auth.transport import _mtls_helper
|
|
19
21
|
|
|
@@ -36,6 +38,12 @@ def has_default_client_cert_source():
|
|
|
36
38
|
is not None
|
|
37
39
|
):
|
|
38
40
|
return True
|
|
41
|
+
cert_config_path = getenv("GOOGLE_API_CERTIFICATE_CONFIG")
|
|
42
|
+
if (
|
|
43
|
+
cert_config_path
|
|
44
|
+
and _mtls_helper._check_config_path(cert_config_path) is not None
|
|
45
|
+
):
|
|
46
|
+
return True
|
|
39
47
|
return False
|
|
40
48
|
|
|
41
49
|
|