google-auth 2.62.1__tar.gz → 2.62.2__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.
Files changed (200) hide show
  1. {google_auth-2.62.1/google_auth.egg-info → google_auth-2.62.2}/PKG-INFO +1 -1
  2. {google_auth-2.62.1 → google_auth-2.62.2}/google/auth/jwt.py +21 -10
  3. {google_auth-2.62.1 → google_auth-2.62.2}/google/auth/transport/requests.py +108 -44
  4. {google_auth-2.62.1 → google_auth-2.62.2}/google/auth/transport/urllib3.py +84 -32
  5. {google_auth-2.62.1 → google_auth-2.62.2}/google/auth/version.py +1 -1
  6. {google_auth-2.62.1 → google_auth-2.62.2}/google/oauth2/_id_token_async.py +36 -4
  7. {google_auth-2.62.1 → google_auth-2.62.2}/google/oauth2/id_token.py +37 -4
  8. {google_auth-2.62.1 → google_auth-2.62.2/google_auth.egg-info}/PKG-INFO +1 -1
  9. {google_auth-2.62.1 → google_auth-2.62.2}/tests/oauth2/test_id_token.py +204 -3
  10. {google_auth-2.62.1 → google_auth-2.62.2}/tests/test_jwt.py +58 -0
  11. {google_auth-2.62.1 → google_auth-2.62.2}/tests/transport/test_requests.py +300 -4
  12. {google_auth-2.62.1 → google_auth-2.62.2}/tests/transport/test_urllib3.py +227 -4
  13. {google_auth-2.62.1 → google_auth-2.62.2}/LICENSE +0 -0
  14. {google_auth-2.62.1 → google_auth-2.62.2}/MANIFEST.in +0 -0
  15. {google_auth-2.62.1 → google_auth-2.62.2}/README.rst +0 -0
  16. {google_auth-2.62.1 → google_auth-2.62.2}/google/auth/__init__.py +0 -0
  17. {google_auth-2.62.1 → google_auth-2.62.2}/google/auth/_agent_identity_utils.py +0 -0
  18. {google_auth-2.62.1 → google_auth-2.62.2}/google/auth/_cache.py +0 -0
  19. {google_auth-2.62.1 → google_auth-2.62.2}/google/auth/_cloud_sdk.py +0 -0
  20. {google_auth-2.62.1 → google_auth-2.62.2}/google/auth/_credentials_async.py +0 -0
  21. {google_auth-2.62.1 → google_auth-2.62.2}/google/auth/_credentials_base.py +0 -0
  22. {google_auth-2.62.1 → google_auth-2.62.2}/google/auth/_default.py +0 -0
  23. {google_auth-2.62.1 → google_auth-2.62.2}/google/auth/_default_async.py +0 -0
  24. {google_auth-2.62.1 → google_auth-2.62.2}/google/auth/_exponential_backoff.py +0 -0
  25. {google_auth-2.62.1 → google_auth-2.62.2}/google/auth/_helpers.py +0 -0
  26. {google_auth-2.62.1 → google_auth-2.62.2}/google/auth/_jwt_async.py +0 -0
  27. {google_auth-2.62.1 → google_auth-2.62.2}/google/auth/_oauth2client.py +0 -0
  28. {google_auth-2.62.1 → google_auth-2.62.2}/google/auth/_refresh_worker.py +0 -0
  29. {google_auth-2.62.1 → google_auth-2.62.2}/google/auth/_regional_access_boundary_utils.py +0 -0
  30. {google_auth-2.62.1 → google_auth-2.62.2}/google/auth/_service_account_info.py +0 -0
  31. {google_auth-2.62.1 → google_auth-2.62.2}/google/auth/aio/__init__.py +0 -0
  32. {google_auth-2.62.1 → google_auth-2.62.2}/google/auth/aio/_helpers.py +0 -0
  33. {google_auth-2.62.1 → google_auth-2.62.2}/google/auth/aio/credentials.py +0 -0
  34. {google_auth-2.62.1 → google_auth-2.62.2}/google/auth/aio/transport/__init__.py +0 -0
  35. {google_auth-2.62.1 → google_auth-2.62.2}/google/auth/aio/transport/aiohttp.py +0 -0
  36. {google_auth-2.62.1 → google_auth-2.62.2}/google/auth/aio/transport/mtls.py +0 -0
  37. {google_auth-2.62.1 → google_auth-2.62.2}/google/auth/aio/transport/sessions.py +0 -0
  38. {google_auth-2.62.1 → google_auth-2.62.2}/google/auth/api_key.py +0 -0
  39. {google_auth-2.62.1 → google_auth-2.62.2}/google/auth/app_engine.py +0 -0
  40. {google_auth-2.62.1 → google_auth-2.62.2}/google/auth/aws.py +0 -0
  41. {google_auth-2.62.1 → google_auth-2.62.2}/google/auth/compute_engine/__init__.py +0 -0
  42. {google_auth-2.62.1 → google_auth-2.62.2}/google/auth/compute_engine/_metadata.py +0 -0
  43. {google_auth-2.62.1 → google_auth-2.62.2}/google/auth/compute_engine/_mtls.py +0 -0
  44. {google_auth-2.62.1 → google_auth-2.62.2}/google/auth/compute_engine/credentials.py +0 -0
  45. {google_auth-2.62.1 → google_auth-2.62.2}/google/auth/credentials.py +0 -0
  46. {google_auth-2.62.1 → google_auth-2.62.2}/google/auth/crypt/__init__.py +0 -0
  47. {google_auth-2.62.1 → google_auth-2.62.2}/google/auth/crypt/_cryptography_rsa.py +0 -0
  48. {google_auth-2.62.1 → google_auth-2.62.2}/google/auth/crypt/_helpers.py +0 -0
  49. {google_auth-2.62.1 → google_auth-2.62.2}/google/auth/crypt/_python_rsa.py +0 -0
  50. {google_auth-2.62.1 → google_auth-2.62.2}/google/auth/crypt/base.py +0 -0
  51. {google_auth-2.62.1 → google_auth-2.62.2}/google/auth/crypt/es.py +0 -0
  52. {google_auth-2.62.1 → google_auth-2.62.2}/google/auth/crypt/es256.py +0 -0
  53. {google_auth-2.62.1 → google_auth-2.62.2}/google/auth/crypt/rsa.py +0 -0
  54. {google_auth-2.62.1 → google_auth-2.62.2}/google/auth/downscoped.py +0 -0
  55. {google_auth-2.62.1 → google_auth-2.62.2}/google/auth/environment_vars.py +0 -0
  56. {google_auth-2.62.1 → google_auth-2.62.2}/google/auth/exceptions.py +0 -0
  57. {google_auth-2.62.1 → google_auth-2.62.2}/google/auth/external_account.py +0 -0
  58. {google_auth-2.62.1 → google_auth-2.62.2}/google/auth/external_account_authorized_user.py +0 -0
  59. {google_auth-2.62.1 → google_auth-2.62.2}/google/auth/iam.py +0 -0
  60. {google_auth-2.62.1 → google_auth-2.62.2}/google/auth/identity_pool.py +0 -0
  61. {google_auth-2.62.1 → google_auth-2.62.2}/google/auth/impersonated_credentials.py +0 -0
  62. {google_auth-2.62.1 → google_auth-2.62.2}/google/auth/metrics.py +0 -0
  63. {google_auth-2.62.1 → google_auth-2.62.2}/google/auth/pluggable.py +0 -0
  64. {google_auth-2.62.1 → google_auth-2.62.2}/google/auth/py.typed +0 -0
  65. {google_auth-2.62.1 → google_auth-2.62.2}/google/auth/transport/__init__.py +0 -0
  66. {google_auth-2.62.1 → google_auth-2.62.2}/google/auth/transport/_aiohttp_requests.py +0 -0
  67. {google_auth-2.62.1 → google_auth-2.62.2}/google/auth/transport/_custom_tls_signer.py +0 -0
  68. {google_auth-2.62.1 → google_auth-2.62.2}/google/auth/transport/_http_client.py +0 -0
  69. {google_auth-2.62.1 → google_auth-2.62.2}/google/auth/transport/_mtls_helper.py +0 -0
  70. {google_auth-2.62.1 → google_auth-2.62.2}/google/auth/transport/_requests_base.py +0 -0
  71. {google_auth-2.62.1 → google_auth-2.62.2}/google/auth/transport/grpc.py +0 -0
  72. {google_auth-2.62.1 → google_auth-2.62.2}/google/auth/transport/mtls.py +0 -0
  73. {google_auth-2.62.1 → google_auth-2.62.2}/google/oauth2/__init__.py +0 -0
  74. {google_auth-2.62.1 → google_auth-2.62.2}/google/oauth2/_client.py +0 -0
  75. {google_auth-2.62.1 → google_auth-2.62.2}/google/oauth2/_client_async.py +0 -0
  76. {google_auth-2.62.1 → google_auth-2.62.2}/google/oauth2/_credentials_async.py +0 -0
  77. {google_auth-2.62.1 → google_auth-2.62.2}/google/oauth2/_reauth_async.py +0 -0
  78. {google_auth-2.62.1 → google_auth-2.62.2}/google/oauth2/_service_account_async.py +0 -0
  79. {google_auth-2.62.1 → google_auth-2.62.2}/google/oauth2/challenges.py +0 -0
  80. {google_auth-2.62.1 → google_auth-2.62.2}/google/oauth2/credentials.py +0 -0
  81. {google_auth-2.62.1 → google_auth-2.62.2}/google/oauth2/gdch_credentials.py +0 -0
  82. {google_auth-2.62.1 → google_auth-2.62.2}/google/oauth2/py.typed +0 -0
  83. {google_auth-2.62.1 → google_auth-2.62.2}/google/oauth2/reauth.py +0 -0
  84. {google_auth-2.62.1 → google_auth-2.62.2}/google/oauth2/service_account.py +0 -0
  85. {google_auth-2.62.1 → google_auth-2.62.2}/google/oauth2/sts.py +0 -0
  86. {google_auth-2.62.1 → google_auth-2.62.2}/google/oauth2/utils.py +0 -0
  87. {google_auth-2.62.1 → google_auth-2.62.2}/google/oauth2/webauthn_handler.py +0 -0
  88. {google_auth-2.62.1 → google_auth-2.62.2}/google/oauth2/webauthn_handler_factory.py +0 -0
  89. {google_auth-2.62.1 → google_auth-2.62.2}/google/oauth2/webauthn_types.py +0 -0
  90. {google_auth-2.62.1 → google_auth-2.62.2}/google_auth.egg-info/SOURCES.txt +0 -0
  91. {google_auth-2.62.1 → google_auth-2.62.2}/google_auth.egg-info/dependency_links.txt +0 -0
  92. {google_auth-2.62.1 → google_auth-2.62.2}/google_auth.egg-info/requires.txt +0 -0
  93. {google_auth-2.62.1 → google_auth-2.62.2}/google_auth.egg-info/top_level.txt +0 -0
  94. {google_auth-2.62.1 → google_auth-2.62.2}/setup.cfg +0 -0
  95. {google_auth-2.62.1 → google_auth-2.62.2}/setup.py +0 -0
  96. {google_auth-2.62.1 → google_auth-2.62.2}/tests/__init__.py +0 -0
  97. {google_auth-2.62.1 → google_auth-2.62.2}/tests/aio/test__helpers.py +0 -0
  98. {google_auth-2.62.1 → google_auth-2.62.2}/tests/compute_engine/__init__.py +0 -0
  99. {google_auth-2.62.1 → google_auth-2.62.2}/tests/compute_engine/data/smbios_product_name +0 -0
  100. {google_auth-2.62.1 → google_auth-2.62.2}/tests/compute_engine/data/smbios_product_name_non_google +0 -0
  101. {google_auth-2.62.1 → google_auth-2.62.2}/tests/compute_engine/test__metadata.py +0 -0
  102. {google_auth-2.62.1 → google_auth-2.62.2}/tests/compute_engine/test__mtls.py +0 -0
  103. {google_auth-2.62.1 → google_auth-2.62.2}/tests/compute_engine/test_credentials.py +0 -0
  104. {google_auth-2.62.1 → google_auth-2.62.2}/tests/conftest.py +0 -0
  105. {google_auth-2.62.1 → google_auth-2.62.2}/tests/crypt/__init__.py +0 -0
  106. {google_auth-2.62.1 → google_auth-2.62.2}/tests/crypt/test__cryptography_rsa.py +0 -0
  107. {google_auth-2.62.1 → google_auth-2.62.2}/tests/crypt/test__python_rsa.py +0 -0
  108. {google_auth-2.62.1 → google_auth-2.62.2}/tests/crypt/test_crypt.py +0 -0
  109. {google_auth-2.62.1 → google_auth-2.62.2}/tests/crypt/test_es.py +0 -0
  110. {google_auth-2.62.1 → google_auth-2.62.2}/tests/crypt/test_es256.py +0 -0
  111. {google_auth-2.62.1 → google_auth-2.62.2}/tests/crypt/test_rsa.py +0 -0
  112. {google_auth-2.62.1 → google_auth-2.62.2}/tests/data/authorized_user.json +0 -0
  113. {google_auth-2.62.1 → google_auth-2.62.2}/tests/data/authorized_user_cloud_sdk.json +0 -0
  114. {google_auth-2.62.1 → google_auth-2.62.2}/tests/data/authorized_user_cloud_sdk_with_quota_project_id.json +0 -0
  115. {google_auth-2.62.1 → google_auth-2.62.2}/tests/data/authorized_user_with_rapt_token.json +0 -0
  116. {google_auth-2.62.1 → google_auth-2.62.2}/tests/data/client_secrets.json +0 -0
  117. {google_auth-2.62.1 → google_auth-2.62.2}/tests/data/context_aware_metadata.json +0 -0
  118. {google_auth-2.62.1 → google_auth-2.62.2}/tests/data/enterprise_cert_invalid.json +0 -0
  119. {google_auth-2.62.1 → google_auth-2.62.2}/tests/data/enterprise_cert_valid.json +0 -0
  120. {google_auth-2.62.1 → google_auth-2.62.2}/tests/data/enterprise_cert_valid_provider.json +0 -0
  121. {google_auth-2.62.1 → google_auth-2.62.2}/tests/data/es256_privatekey.pem +0 -0
  122. {google_auth-2.62.1 → google_auth-2.62.2}/tests/data/es256_public_cert.pem +0 -0
  123. {google_auth-2.62.1 → google_auth-2.62.2}/tests/data/es256_publickey.pem +0 -0
  124. {google_auth-2.62.1 → google_auth-2.62.2}/tests/data/es256_service_account.json +0 -0
  125. {google_auth-2.62.1 → google_auth-2.62.2}/tests/data/es384_privatekey.pem +0 -0
  126. {google_auth-2.62.1 → google_auth-2.62.2}/tests/data/es384_public_cert.pem +0 -0
  127. {google_auth-2.62.1 → google_auth-2.62.2}/tests/data/es384_publickey.pem +0 -0
  128. {google_auth-2.62.1 → google_auth-2.62.2}/tests/data/es384_service_account.json +0 -0
  129. {google_auth-2.62.1 → google_auth-2.62.2}/tests/data/external_account_authorized_user.json +0 -0
  130. {google_auth-2.62.1 → google_auth-2.62.2}/tests/data/external_account_authorized_user_non_gdu.json +0 -0
  131. {google_auth-2.62.1 → google_auth-2.62.2}/tests/data/external_subject_token.json +0 -0
  132. {google_auth-2.62.1 → google_auth-2.62.2}/tests/data/external_subject_token.txt +0 -0
  133. {google_auth-2.62.1 → google_auth-2.62.2}/tests/data/gdch_service_account.json +0 -0
  134. {google_auth-2.62.1 → google_auth-2.62.2}/tests/data/impersonated_service_account_authorized_user_source.json +0 -0
  135. {google_auth-2.62.1 → google_auth-2.62.2}/tests/data/impersonated_service_account_external_account_authorized_user_source.json +0 -0
  136. {google_auth-2.62.1 → google_auth-2.62.2}/tests/data/impersonated_service_account_service_account_source.json +0 -0
  137. {google_auth-2.62.1 → google_auth-2.62.2}/tests/data/impersonated_service_account_with_quota_project.json +0 -0
  138. {google_auth-2.62.1 → google_auth-2.62.2}/tests/data/old_oauth_credentials_py3.pickle +0 -0
  139. {google_auth-2.62.1 → google_auth-2.62.2}/tests/data/other_cert.pem +0 -0
  140. {google_auth-2.62.1 → google_auth-2.62.2}/tests/data/pem_from_pkcs12.pem +0 -0
  141. {google_auth-2.62.1 → google_auth-2.62.2}/tests/data/privatekey.p12 +0 -0
  142. {google_auth-2.62.1 → google_auth-2.62.2}/tests/data/privatekey.pem +0 -0
  143. {google_auth-2.62.1 → google_auth-2.62.2}/tests/data/privatekey.pub +0 -0
  144. {google_auth-2.62.1 → google_auth-2.62.2}/tests/data/public_cert.pem +0 -0
  145. {google_auth-2.62.1 → google_auth-2.62.2}/tests/data/service_account.json +0 -0
  146. {google_auth-2.62.1 → google_auth-2.62.2}/tests/data/service_account_non_gdu.json +0 -0
  147. {google_auth-2.62.1 → google_auth-2.62.2}/tests/data/trust_chain_with_leaf.pem +0 -0
  148. {google_auth-2.62.1 → google_auth-2.62.2}/tests/data/trust_chain_without_leaf.pem +0 -0
  149. {google_auth-2.62.1 → google_auth-2.62.2}/tests/data/trust_chain_wrong_order.pem +0 -0
  150. {google_auth-2.62.1 → google_auth-2.62.2}/tests/oauth2/__init__.py +0 -0
  151. {google_auth-2.62.1 → google_auth-2.62.2}/tests/oauth2/test__client.py +0 -0
  152. {google_auth-2.62.1 → google_auth-2.62.2}/tests/oauth2/test_challenges.py +0 -0
  153. {google_auth-2.62.1 → google_auth-2.62.2}/tests/oauth2/test_credentials.py +0 -0
  154. {google_auth-2.62.1 → google_auth-2.62.2}/tests/oauth2/test_gdch_credentials.py +0 -0
  155. {google_auth-2.62.1 → google_auth-2.62.2}/tests/oauth2/test_reauth.py +0 -0
  156. {google_auth-2.62.1 → google_auth-2.62.2}/tests/oauth2/test_service_account.py +0 -0
  157. {google_auth-2.62.1 → google_auth-2.62.2}/tests/oauth2/test_sts.py +0 -0
  158. {google_auth-2.62.1 → google_auth-2.62.2}/tests/oauth2/test_utils.py +0 -0
  159. {google_auth-2.62.1 → google_auth-2.62.2}/tests/oauth2/test_webauthn_handler.py +0 -0
  160. {google_auth-2.62.1 → google_auth-2.62.2}/tests/oauth2/test_webauthn_handler_factory.py +0 -0
  161. {google_auth-2.62.1 → google_auth-2.62.2}/tests/oauth2/test_webauthn_types.py +0 -0
  162. {google_auth-2.62.1 → google_auth-2.62.2}/tests/test__cache.py +0 -0
  163. {google_auth-2.62.1 → google_auth-2.62.2}/tests/test__cloud_sdk.py +0 -0
  164. {google_auth-2.62.1 → google_auth-2.62.2}/tests/test__default.py +0 -0
  165. {google_auth-2.62.1 → google_auth-2.62.2}/tests/test__exponential_backoff.py +0 -0
  166. {google_auth-2.62.1 → google_auth-2.62.2}/tests/test__helpers.py +0 -0
  167. {google_auth-2.62.1 → google_auth-2.62.2}/tests/test__oauth2client.py +0 -0
  168. {google_auth-2.62.1 → google_auth-2.62.2}/tests/test__refresh_worker.py +0 -0
  169. {google_auth-2.62.1 → google_auth-2.62.2}/tests/test__regional_access_boundary_utils.py +0 -0
  170. {google_auth-2.62.1 → google_auth-2.62.2}/tests/test__service_account_info.py +0 -0
  171. {google_auth-2.62.1 → google_auth-2.62.2}/tests/test_agent_identity_utils.py +0 -0
  172. {google_auth-2.62.1 → google_auth-2.62.2}/tests/test_api_key.py +0 -0
  173. {google_auth-2.62.1 → google_auth-2.62.2}/tests/test_app_engine.py +0 -0
  174. {google_auth-2.62.1 → google_auth-2.62.2}/tests/test_aws.py +0 -0
  175. {google_auth-2.62.1 → google_auth-2.62.2}/tests/test_credentials.py +0 -0
  176. {google_auth-2.62.1 → google_auth-2.62.2}/tests/test_credentials_async.py +0 -0
  177. {google_auth-2.62.1 → google_auth-2.62.2}/tests/test_downscoped.py +0 -0
  178. {google_auth-2.62.1 → google_auth-2.62.2}/tests/test_exceptions.py +0 -0
  179. {google_auth-2.62.1 → google_auth-2.62.2}/tests/test_external_account.py +0 -0
  180. {google_auth-2.62.1 → google_auth-2.62.2}/tests/test_external_account_authorized_user.py +0 -0
  181. {google_auth-2.62.1 → google_auth-2.62.2}/tests/test_iam.py +0 -0
  182. {google_auth-2.62.1 → google_auth-2.62.2}/tests/test_identity_pool.py +0 -0
  183. {google_auth-2.62.1 → google_auth-2.62.2}/tests/test_impersonated_credentials.py +0 -0
  184. {google_auth-2.62.1 → google_auth-2.62.2}/tests/test_metrics.py +0 -0
  185. {google_auth-2.62.1 → google_auth-2.62.2}/tests/test_packaging.py +0 -0
  186. {google_auth-2.62.1 → google_auth-2.62.2}/tests/test_pluggable.py +0 -0
  187. {google_auth-2.62.1 → google_auth-2.62.2}/tests/transport/__init__.py +0 -0
  188. {google_auth-2.62.1 → google_auth-2.62.2}/tests/transport/aio/conftest.py +0 -0
  189. {google_auth-2.62.1 → google_auth-2.62.2}/tests/transport/aio/test_aiohttp.py +0 -0
  190. {google_auth-2.62.1 → google_auth-2.62.2}/tests/transport/aio/test_mtls.py +0 -0
  191. {google_auth-2.62.1 → google_auth-2.62.2}/tests/transport/aio/test_sessions.py +0 -0
  192. {google_auth-2.62.1 → google_auth-2.62.2}/tests/transport/aio/test_sessions_mtls.py +0 -0
  193. {google_auth-2.62.1 → google_auth-2.62.2}/tests/transport/aioresponses_compat.py +0 -0
  194. {google_auth-2.62.1 → google_auth-2.62.2}/tests/transport/compliance.py +0 -0
  195. {google_auth-2.62.1 → google_auth-2.62.2}/tests/transport/test__custom_tls_signer.py +0 -0
  196. {google_auth-2.62.1 → google_auth-2.62.2}/tests/transport/test__http_client.py +0 -0
  197. {google_auth-2.62.1 → google_auth-2.62.2}/tests/transport/test__mtls_helper.py +0 -0
  198. {google_auth-2.62.1 → google_auth-2.62.2}/tests/transport/test_aio_mtls_helper.py +0 -0
  199. {google_auth-2.62.1 → google_auth-2.62.2}/tests/transport/test_grpc.py +0 -0
  200. {google_auth-2.62.1 → google_auth-2.62.2}/tests/transport/test_mtls.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: google-auth
3
- Version: 2.62.1
3
+ Version: 2.62.2
4
4
  Summary: Google Authentication Library
5
5
  Home-page: https://github.com/googleapis/google-cloud-python/tree/main/packages/google-auth
6
6
  Author: Google Cloud Platform
@@ -41,10 +41,10 @@ You can also skip verification::
41
41
  """
42
42
 
43
43
  try:
44
- from collections.abc import Mapping
44
+ from collections.abc import Iterable, Mapping
45
45
  # Python 2.7 compatibility
46
46
  except ImportError: # pragma: NO COVER
47
- from collections import Mapping # type: ignore
47
+ from collections import Iterable, Mapping # type: ignore
48
48
  import copy
49
49
  import datetime
50
50
  import json
@@ -269,8 +269,8 @@ def decode(token, certs=None, verify=True, audience=None, clock_skew_in_seconds=
269
269
 
270
270
  try:
271
271
  verifier_cls = _ALGORITHM_TO_VERIFIER_CLASS[key_alg]
272
- except KeyError as exc:
273
- if key_alg in _CRYPTOGRAPHY_BASED_ALGORITHMS:
272
+ except (KeyError, TypeError) as exc:
273
+ if isinstance(key_alg, str) and key_alg in _CRYPTOGRAPHY_BASED_ALGORITHMS:
274
274
  raise exceptions.InvalidValue(
275
275
  "The key algorithm {} requires the cryptography package to be installed.".format(
276
276
  key_alg
@@ -284,11 +284,12 @@ def decode(token, certs=None, verify=True, audience=None, clock_skew_in_seconds=
284
284
  # use the certificate identified by the key ID in the token header.
285
285
  if isinstance(certs, Mapping):
286
286
  if key_id:
287
- if key_id not in certs:
287
+ try:
288
+ certs_to_check = [certs[key_id]]
289
+ except (KeyError, TypeError) as exc:
288
290
  raise exceptions.MalformedError(
289
291
  "Certificate for key id {} not found.".format(key_id)
290
- )
291
- certs_to_check = [certs[key_id]]
292
+ ) from exc
292
293
  # If there's no key id in the header, check against all of the certs.
293
294
  else:
294
295
  certs_to_check = certs.values()
@@ -296,9 +297,19 @@ def decode(token, certs=None, verify=True, audience=None, clock_skew_in_seconds=
296
297
  certs_to_check = certs
297
298
 
298
299
  # Verify that the signature matches the message.
299
- if not crypt.verify_signature(
300
- signed_section, signature, certs_to_check, verifier_cls
301
- ):
300
+ try:
301
+ valid_signature = crypt.verify_signature(
302
+ signed_section, signature, certs_to_check, verifier_cls
303
+ )
304
+ except TypeError as exc:
305
+ if not isinstance(certs_to_check, Iterable):
306
+ raise
307
+ raise exceptions.InvalidValue(
308
+ "Certificate key type does not match signature algorithm {}.".format(
309
+ key_alg
310
+ )
311
+ ) from exc
312
+ if not valid_signature:
302
313
  raise exceptions.MalformedError("Could not verify token signature.")
303
314
 
304
315
  # Verify the issued at and created times in the payload.
@@ -116,6 +116,31 @@ class TimeoutGuard(object):
116
116
  raise self._timeout_error_type()
117
117
 
118
118
 
119
+ def _replace_adapter(session, prefix, adapter):
120
+ """Mounts an adapter on a session without mutating its adapters in place.
121
+
122
+ ``adapter`` is mounted on ``session`` for ``prefix``.
123
+ :meth:`requests.Session.mount` mutates the ``session.adapters``
124
+ OrderedDict in place. If another thread is iterating over it in
125
+ :meth:`requests.Session.get_adapter` at the same time, that thread fails
126
+ with ``RuntimeError: OrderedDict mutated during iteration``. This builds
127
+ an updated copy and assigns it in one step instead, so threads that are
128
+ already iterating over the old dictionary are not affected.
129
+
130
+ Args:
131
+ session (requests.Session): The session to mount the adapter on.
132
+ prefix (str): The URL prefix to mount the adapter for.
133
+ adapter (requests.adapters.BaseAdapter): The adapter to mount.
134
+ """
135
+ new_adapters = session.adapters.copy()
136
+ new_adapters[prefix] = adapter
137
+ # Keep the longest prefixes first, as requests.Session.mount() does, so
138
+ # that get_adapter() matches the most specific prefix.
139
+ session.adapters = collections.OrderedDict(
140
+ sorted(new_adapters.items(), key=lambda item: len(item[0]), reverse=True)
141
+ )
142
+
143
+
119
144
  class Request(transport.Request):
120
145
  """Requests request adapter.
121
146
 
@@ -213,18 +238,7 @@ class Request(transport.Request):
213
238
  pool_block=session_adapter._pool_block,
214
239
  )
215
240
 
216
- # Replace session.adapters atomically instead of calling session.mount(),
217
- # which mutates the OrderedDict in place and can raise RuntimeError if
218
- # another thread is iterating over session.adapters in get_adapter().
219
- new_adapters = self.session.adapters.copy()
220
- new_adapters[prefix] = self._mtls_adapter
221
- self.session.adapters = collections.OrderedDict(
222
- sorted(
223
- new_adapters.items(),
224
- key=lambda item: len(item[0]),
225
- reverse=True,
226
- )
227
- )
241
+ _replace_adapter(self.session, prefix, self._mtls_adapter)
228
242
 
229
243
  def __call__(
230
244
  self,
@@ -514,6 +528,7 @@ class AuthorizedSession(requests.Session):
514
528
  self._refresh_timeout = refresh_timeout
515
529
  self._is_mtls = False
516
530
  self._default_host = default_host
531
+ self._mtls_reauth_lock = threading.Lock()
517
532
 
518
533
  if auth_request is None:
519
534
  self._auth_request_session = requests.Session()
@@ -558,9 +573,9 @@ class AuthorizedSession(requests.Session):
558
573
  will be used.
559
574
 
560
575
  .. warning::
561
- Calling this method mutates the underlying `requests.Session` adapter
562
- dictionary. It is not thread-safe to call this explicitly while other
563
- threads are making requests.
576
+ Calling this method replaces the underlying `requests.Session`
577
+ adapters and closes the previous ones. It is not thread-safe to call
578
+ this explicitly while other threads are making requests.
564
579
 
565
580
  Raises:
566
581
  google.auth.exceptions.MutualTLSChannelError: If mutual TLS channel
@@ -641,13 +656,13 @@ class AuthorizedSession(requests.Session):
641
656
  new_exc = exceptions.MutualTLSChannelError(caught_exc)
642
657
  raise new_exc from caught_exc
643
658
 
644
- self.mount("https://", new_adapter)
659
+ _replace_adapter(self, "https://", new_adapter)
645
660
 
646
661
  if old_adapter is not None and old_adapter is not new_adapter:
647
662
  old_adapter.close()
648
663
 
649
664
  if self._auth_request_session is not None and new_auth_adapter is not None:
650
- self._auth_request_session.mount("https://", new_auth_adapter)
665
+ _replace_adapter(self._auth_request_session, "https://", new_auth_adapter)
651
666
 
652
667
  if (
653
668
  old_auth_adapter is not None
@@ -724,6 +739,11 @@ class AuthorizedSession(requests.Session):
724
739
  self.credentials.before_request(auth_request, method, url, request_headers)
725
740
  remaining_time = guard.remaining_timeout
726
741
 
742
+ # Remember the client certificate that this request is sent with. If
743
+ # the request receives a 401 response, this tells whether another
744
+ # thread has already rotated the certificate in the meantime.
745
+ cert_at_request = getattr(self, "_cached_cert", None)
746
+
727
747
  with TimeoutGuard(remaining_time) as guard:
728
748
  _helpers.request_log(_LOGGER, method, url, data, headers)
729
749
  response = super(AuthorizedSession, self).request(
@@ -749,33 +769,9 @@ class AuthorizedSession(requests.Session):
749
769
  if response.status_code == http_client.UNAUTHORIZED:
750
770
  use_mtls = self.is_mtls and _mtls_helper.is_mtls_endpoint(url)
751
771
  if use_mtls:
752
- (
753
- call_cert_bytes,
754
- call_key_bytes,
755
- cached_fingerprint,
756
- current_cert_fingerprint,
757
- ) = _mtls_helper.check_parameters_for_unauthorized_response(
758
- self._cached_cert
759
- )
760
- if cached_fingerprint != current_cert_fingerprint:
761
- try:
762
- _LOGGER.info(
763
- "Client certificate has changed, reconfiguring mTLS "
764
- "channel."
765
- )
766
- self.configure_mtls_channel(
767
- lambda: (call_cert_bytes, call_key_bytes)
768
- )
769
- except Exception as e:
770
- _LOGGER.error("Failed to reconfigure mTLS channel: %s", e)
771
- raise exceptions.MutualTLSChannelError(
772
- "Failed to reconfigure mTLS channel"
773
- ) from e
774
- else:
775
- _LOGGER.info(
776
- "Skipping reconfiguration of mTLS channel because the client"
777
- " certificate has not changed."
778
- )
772
+ with TimeoutGuard(remaining_time) as guard:
773
+ self._reconfigure_mtls_channel_if_cert_changed(cert_at_request)
774
+ remaining_time = guard.remaining_timeout
779
775
  _LOGGER.info(
780
776
  "Refreshing credentials due to a %s response. Attempt %s/%s.",
781
777
  response.status_code,
@@ -810,6 +806,74 @@ class AuthorizedSession(requests.Session):
810
806
 
811
807
  return response
812
808
 
809
+ def _reconfigure_mtls_channel_if_cert_changed(self, cert_at_request):
810
+ """Reconfigures the mTLS channel if the client certificate has changed.
811
+
812
+ This is called when a request to an mTLS endpoint receives a 401
813
+ response. The certificate check and the channel reconfiguration run
814
+ while holding ``_mtls_reauth_lock``. When several threads receive a 401
815
+ response at the same time, only the first one reads the current
816
+ certificate and remounts the adapters. The other threads see that the
817
+ channel has already been reconfigured and reuse it.
818
+
819
+ Args:
820
+ cert_at_request (Optional[bytes]): The cached client certificate at
821
+ the time the request that received the 401 response was sent.
822
+
823
+ Raises:
824
+ google.auth.exceptions.MutualTLSChannelError: If the client
825
+ certificate has changed but the mTLS channel could not be
826
+ reconfigured.
827
+ """
828
+ with self._mtls_reauth_lock:
829
+ if not self.is_mtls:
830
+ # mTLS was disabled by another thread while this one waited.
831
+ return
832
+
833
+ if getattr(self, "_cached_cert", None) != cert_at_request:
834
+ _LOGGER.info(
835
+ "Skipping reconfiguration of mTLS channel because it has already"
836
+ " been reconfigured with a new client certificate."
837
+ )
838
+ return
839
+
840
+ try:
841
+ (
842
+ call_cert_bytes,
843
+ call_key_bytes,
844
+ cached_fingerprint,
845
+ current_cert_fingerprint,
846
+ ) = _mtls_helper.check_parameters_for_unauthorized_response(
847
+ cert_at_request
848
+ )
849
+ except Exception as e:
850
+ # Failing to load the current certificate (for example, because
851
+ # the certificate file is missing or the certificate provider
852
+ # failed) must not prevent the token refresh that follows.
853
+ _LOGGER.warning(
854
+ "Failed to check whether the client certificate has changed: %s",
855
+ e,
856
+ )
857
+ return
858
+
859
+ if cached_fingerprint == current_cert_fingerprint:
860
+ _LOGGER.info(
861
+ "Skipping reconfiguration of mTLS channel because the client"
862
+ " certificate has not changed."
863
+ )
864
+ return
865
+
866
+ try:
867
+ _LOGGER.info(
868
+ "Client certificate has changed, reconfiguring mTLS channel."
869
+ )
870
+ self.configure_mtls_channel(lambda: (call_cert_bytes, call_key_bytes))
871
+ except Exception as e:
872
+ _LOGGER.error("Failed to reconfigure mTLS channel: %s", e)
873
+ raise exceptions.MutualTLSChannelError(
874
+ "Failed to reconfigure mTLS channel"
875
+ ) from e
876
+
813
877
  @property
814
878
  def is_mtls(self):
815
879
  """Indicates if the created SSL channel is mutual TLS."""
@@ -18,6 +18,7 @@ from __future__ import absolute_import
18
18
 
19
19
  import http.client as http_client
20
20
  import logging
21
+ import threading
21
22
  import warnings
22
23
 
23
24
  # Certifi is Mozilla's certificate bundle. Urllib3 needs a certificate bundle
@@ -308,6 +309,7 @@ class AuthorizedHttp(RequestMethods): # type: ignore
308
309
  # credentials.refresh).
309
310
  self._request = Request(self.http)
310
311
  self._is_mtls = False
312
+ self._mtls_reauth_lock = threading.Lock()
311
313
 
312
314
  # https://google.aip.dev/auth/4111
313
315
  # Attempt to use self-signed JWTs when a service account is used.
@@ -318,6 +320,11 @@ class AuthorizedHttp(RequestMethods): # type: ignore
318
320
 
319
321
  super(AuthorizedHttp, self).__init__()
320
322
 
323
+ @property
324
+ def is_mtls(self):
325
+ """Indicates if the created SSL channel is mutual TLS."""
326
+ return self._is_mtls
327
+
321
328
  def configure_mtls_channel(self, client_cert_callback=None):
322
329
  """Configures mutual TLS channel using the given client_cert_callback or
323
330
  application default SSL credentials.
@@ -414,6 +421,11 @@ class AuthorizedHttp(RequestMethods): # type: ignore
414
421
 
415
422
  self.credentials.before_request(self._request, method, url, request_headers)
416
423
 
424
+ # Remember the client certificate that this request is sent with. If
425
+ # the request receives a 401 response, this tells whether another
426
+ # thread has already rotated the certificate in the meantime.
427
+ cert_at_request = getattr(self, "_cached_cert", None)
428
+
417
429
  response = self.http.urlopen(
418
430
  method, url, body=body, headers=request_headers, **kwargs
419
431
  )
@@ -430,39 +442,9 @@ class AuthorizedHttp(RequestMethods): # type: ignore
430
442
  and _credential_refresh_attempt < self._max_refresh_attempts
431
443
  ):
432
444
  if response.status == http_client.UNAUTHORIZED:
433
- use_mtls = self._is_mtls and _mtls_helper.is_mtls_endpoint(url)
445
+ use_mtls = self.is_mtls and _mtls_helper.is_mtls_endpoint(url)
434
446
  if use_mtls:
435
- (
436
- call_cert_bytes,
437
- call_key_bytes,
438
- cached_fingerprint,
439
- current_cert_fingerprint,
440
- ) = _mtls_helper.check_parameters_for_unauthorized_response(
441
- self._cached_cert
442
- )
443
- if cached_fingerprint != current_cert_fingerprint:
444
- try:
445
- _LOGGER.info(
446
- "Client certificate has changed, reconfiguring mTLS "
447
- "channel."
448
- )
449
- self.configure_mtls_channel(
450
- client_cert_callback=lambda: (
451
- call_cert_bytes,
452
- call_key_bytes,
453
- )
454
- )
455
- except Exception as e:
456
- _LOGGER.error("Failed to reconfigure mTLS channel: %s", e)
457
- raise exceptions.MutualTLSChannelError(
458
- "Failed to reconfigure mTLS channel"
459
- ) from e
460
-
461
- else:
462
- _LOGGER.info(
463
- "Skipping reconfiguration of mTLS channel because the "
464
- "client certificate has not changed."
465
- )
447
+ self._reconfigure_mtls_channel_if_cert_changed(cert_at_request)
466
448
 
467
449
  _LOGGER.info(
468
450
  "Refreshing credentials due to a %s response. Attempt %s/%s.",
@@ -485,6 +467,76 @@ class AuthorizedHttp(RequestMethods): # type: ignore
485
467
 
486
468
  return response
487
469
 
470
+ def _reconfigure_mtls_channel_if_cert_changed(self, cert_at_request):
471
+ """Reconfigures the mTLS channel if the client certificate has changed.
472
+
473
+ This is called when a request to an mTLS endpoint receives a 401
474
+ response. The certificate check and the channel reconfiguration run
475
+ while holding ``_mtls_reauth_lock``. When several threads receive a 401
476
+ response at the same time, only the first one reads the current
477
+ certificate and replaces the pool manager. The other threads see that
478
+ the channel has already been reconfigured and reuse it.
479
+
480
+ Args:
481
+ cert_at_request (Optional[bytes]): The cached client certificate at
482
+ the time the request that received the 401 response was sent.
483
+
484
+ Raises:
485
+ google.auth.exceptions.MutualTLSChannelError: If the client
486
+ certificate has changed but the mTLS channel could not be
487
+ reconfigured.
488
+ """
489
+ with self._mtls_reauth_lock:
490
+ if not self.is_mtls:
491
+ # mTLS was disabled by another thread while this one waited.
492
+ return
493
+
494
+ if getattr(self, "_cached_cert", None) != cert_at_request:
495
+ _LOGGER.info(
496
+ "Skipping reconfiguration of mTLS channel because it has already"
497
+ " been reconfigured with a new client certificate."
498
+ )
499
+ return
500
+
501
+ try:
502
+ (
503
+ call_cert_bytes,
504
+ call_key_bytes,
505
+ cached_fingerprint,
506
+ current_cert_fingerprint,
507
+ ) = _mtls_helper.check_parameters_for_unauthorized_response(
508
+ cert_at_request
509
+ )
510
+ except Exception as e:
511
+ # Failing to load the current certificate (for example, because
512
+ # the certificate file is missing or the certificate provider
513
+ # failed) must not prevent the token refresh that follows.
514
+ _LOGGER.warning(
515
+ "Failed to check whether the client certificate has changed: %s",
516
+ e,
517
+ )
518
+ return
519
+
520
+ if cached_fingerprint == current_cert_fingerprint:
521
+ _LOGGER.info(
522
+ "Skipping reconfiguration of mTLS channel because the "
523
+ "client certificate has not changed."
524
+ )
525
+ return
526
+
527
+ try:
528
+ _LOGGER.info(
529
+ "Client certificate has changed, reconfiguring mTLS channel."
530
+ )
531
+ self.configure_mtls_channel(
532
+ client_cert_callback=lambda: (call_cert_bytes, call_key_bytes)
533
+ )
534
+ except Exception as e:
535
+ _LOGGER.error("Failed to reconfigure mTLS channel: %s", e)
536
+ raise exceptions.MutualTLSChannelError(
537
+ "Failed to reconfigure mTLS channel"
538
+ ) from e
539
+
488
540
  # Proxy methods for compliance with the urllib3.PoolManager interface
489
541
 
490
542
  def __enter__(self):
@@ -12,4 +12,4 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- __version__ = "2.62.1"
15
+ __version__ = "2.62.2"
@@ -61,6 +61,7 @@ library like `CacheControl`_ to create a cache-aware
61
61
  import http.client as http_client
62
62
  import json
63
63
  import os
64
+ import warnings
64
65
 
65
66
  from google.auth import environment_vars, exceptions, jwt
66
67
  from google.auth.transport import requests
@@ -176,16 +177,31 @@ async def verify_firebase_token(
176
177
  id_token (Union[str, bytes]): The encoded token.
177
178
  request (google.auth.transport.Request): The object used to make
178
179
  HTTP requests. This must be an aiohttp request.
179
- audience (str): The audience that this token is intended for. This is
180
- typically your Firebase application ID. If None then the audience
181
- is not verified.
180
+ audience (Optional[Union[str, Iterable[str]]]): The audience that this
181
+ token is intended for. This is your Firebase project ID. If
182
+ ``None`` or empty, the audience will be left unverified, and a
183
+ ``UserWarning`` is issued. Passing a non-empty ``audience`` will be
184
+ required in a future release.
182
185
  clock_skew_in_seconds (int): The clock skew used for `iat` and `exp`
183
186
  validation.
184
187
 
185
188
  Returns:
186
189
  Mapping[str, Any]: The decoded token.
190
+
191
+ Raises:
192
+ exceptions.InvalidValue: If the issuer, audience, or subject is invalid.
193
+ ValueError: If token verification fails.
187
194
  """
188
- return await verify_token(
195
+ if not audience:
196
+ warnings.warn(
197
+ "Calling verify_firebase_token without an 'audience' leaves the "
198
+ "token's audience claim unverified. Pass your Firebase project ID "
199
+ "as 'audience', which will be required in a future release.",
200
+ UserWarning,
201
+ stacklevel=2,
202
+ )
203
+
204
+ idinfo = await verify_token(
189
205
  id_token,
190
206
  request,
191
207
  audience=audience,
@@ -193,6 +209,22 @@ async def verify_firebase_token(
193
209
  clock_skew_in_seconds=clock_skew_in_seconds,
194
210
  )
195
211
 
212
+ token_aud = idinfo.get("aud")
213
+ if not isinstance(token_aud, str) or not token_aud:
214
+ raise exceptions.InvalidValue("Token does not contain a valid 'aud' claim.")
215
+
216
+ expected_issuer = "{}{}".format(sync_id_token._FIREBASE_ISSUER_PREFIX, token_aud)
217
+ if idinfo.get("iss") != expected_issuer:
218
+ raise exceptions.InvalidValue(
219
+ "Wrong issuer. 'iss' should be '{}'.".format(expected_issuer)
220
+ )
221
+
222
+ token_sub = idinfo.get("sub")
223
+ if not isinstance(token_sub, str) or not token_sub:
224
+ raise exceptions.InvalidValue("Token does not contain a valid 'sub' claim.")
225
+
226
+ return idinfo
227
+
196
228
 
197
229
  async def fetch_id_token(request, audience, bind_id_token=None):
198
230
  """Fetch the ID Token from the current environment.
@@ -60,6 +60,7 @@ from __future__ import annotations
60
60
  import http.client as http_client
61
61
  import json
62
62
  import os
63
+ import warnings
63
64
  from typing import Any, Mapping, Union
64
65
 
65
66
  from google.auth import environment_vars, exceptions, jwt, transport
@@ -76,6 +77,7 @@ _GOOGLE_APIS_CERTS_URL = (
76
77
  )
77
78
 
78
79
  _GOOGLE_ISSUERS = ["accounts.google.com", "https://accounts.google.com"]
80
+ _FIREBASE_ISSUER_PREFIX = "https://securetoken.google.com/"
79
81
 
80
82
 
81
83
  def _fetch_certs(request, certs_url):
@@ -218,16 +220,31 @@ def verify_firebase_token(id_token, request, audience=None, clock_skew_in_second
218
220
  id_token (Union[str, bytes]): The encoded token.
219
221
  request (google.auth.transport.Request): The object used to make
220
222
  HTTP requests.
221
- audience (str): The audience that this token is intended for. This is
222
- typically your Firebase application ID. If None then the audience
223
- is not verified.
223
+ audience (Optional[Union[str, Iterable[str]]]): The audience that this
224
+ token is intended for. This is your Firebase project ID. If
225
+ ``None`` or empty, the audience will be left unverified, and a
226
+ ``UserWarning`` is issued. Passing a non-empty ``audience`` will be
227
+ required in a future release.
224
228
  clock_skew_in_seconds (int): The clock skew used for `iat` and `exp`
225
229
  validation.
226
230
 
227
231
  Returns:
228
232
  Mapping[str, Any]: The decoded token.
233
+
234
+ Raises:
235
+ exceptions.InvalidValue: If the issuer, audience, or subject is invalid.
236
+ ValueError: If token verification fails.
229
237
  """
230
- return verify_token(
238
+ if not audience:
239
+ warnings.warn(
240
+ "Calling verify_firebase_token without an 'audience' leaves the "
241
+ "token's audience claim unverified. Pass your Firebase project ID "
242
+ "as 'audience', which will be required in a future release.",
243
+ UserWarning,
244
+ stacklevel=2,
245
+ )
246
+
247
+ idinfo = verify_token(
231
248
  id_token,
232
249
  request,
233
250
  audience=audience,
@@ -235,6 +252,22 @@ def verify_firebase_token(id_token, request, audience=None, clock_skew_in_second
235
252
  clock_skew_in_seconds=clock_skew_in_seconds,
236
253
  )
237
254
 
255
+ token_aud = idinfo.get("aud")
256
+ if not isinstance(token_aud, str) or not token_aud:
257
+ raise exceptions.InvalidValue("Token does not contain a valid 'aud' claim.")
258
+
259
+ expected_issuer = "{}{}".format(_FIREBASE_ISSUER_PREFIX, token_aud)
260
+ if idinfo.get("iss") != expected_issuer:
261
+ raise exceptions.InvalidValue(
262
+ "Wrong issuer. 'iss' should be '{}'.".format(expected_issuer)
263
+ )
264
+
265
+ token_sub = idinfo.get("sub")
266
+ if not isinstance(token_sub, str) or not token_sub:
267
+ raise exceptions.InvalidValue("Token does not contain a valid 'sub' claim.")
268
+
269
+ return idinfo
270
+
238
271
 
239
272
  def fetch_id_token_credentials(audience, request=None, bind_id_token=None):
240
273
  """Create the ID Token credentials from the current environment.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: google-auth
3
- Version: 2.62.1
3
+ Version: 2.62.2
4
4
  Summary: Google Authentication Library
5
5
  Home-page: https://github.com/googleapis/google-cloud-python/tree/main/packages/google-auth
6
6
  Author: Google Cloud Platform