MNghia commited on
Commit
870360a
·
verified ·
1 Parent(s): 808fec0

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. lib/python3.10/site-packages/google/auth/__pycache__/__init__.cpython-310.pyc +0 -0
  2. lib/python3.10/site-packages/google/auth/__pycache__/_cloud_sdk.cpython-310.pyc +0 -0
  3. lib/python3.10/site-packages/google/auth/__pycache__/_credentials_async.cpython-310.pyc +0 -0
  4. lib/python3.10/site-packages/google/auth/__pycache__/_credentials_base.cpython-310.pyc +0 -0
  5. lib/python3.10/site-packages/google/auth/__pycache__/_default.cpython-310.pyc +0 -0
  6. lib/python3.10/site-packages/google/auth/__pycache__/_default_async.cpython-310.pyc +0 -0
  7. lib/python3.10/site-packages/google/auth/__pycache__/_exponential_backoff.cpython-310.pyc +0 -0
  8. lib/python3.10/site-packages/google/auth/__pycache__/_helpers.cpython-310.pyc +0 -0
  9. lib/python3.10/site-packages/google/auth/__pycache__/_jwt_async.cpython-310.pyc +0 -0
  10. lib/python3.10/site-packages/google/auth/__pycache__/_oauth2client.cpython-310.pyc +0 -0
  11. lib/python3.10/site-packages/google/auth/__pycache__/_refresh_worker.cpython-310.pyc +0 -0
  12. lib/python3.10/site-packages/google/auth/__pycache__/_service_account_info.cpython-310.pyc +0 -0
  13. lib/python3.10/site-packages/google/auth/__pycache__/api_key.cpython-310.pyc +0 -0
  14. lib/python3.10/site-packages/google/auth/__pycache__/app_engine.cpython-310.pyc +0 -0
  15. lib/python3.10/site-packages/google/auth/__pycache__/aws.cpython-310.pyc +0 -0
  16. lib/python3.10/site-packages/google/auth/__pycache__/credentials.cpython-310.pyc +0 -0
  17. lib/python3.10/site-packages/google/auth/__pycache__/downscoped.cpython-310.pyc +0 -0
  18. lib/python3.10/site-packages/google/auth/__pycache__/environment_vars.cpython-310.pyc +0 -0
  19. lib/python3.10/site-packages/google/auth/__pycache__/exceptions.cpython-310.pyc +0 -0
  20. lib/python3.10/site-packages/google/auth/__pycache__/external_account.cpython-310.pyc +0 -0
  21. lib/python3.10/site-packages/google/auth/__pycache__/external_account_authorized_user.cpython-310.pyc +0 -0
  22. lib/python3.10/site-packages/google/auth/__pycache__/iam.cpython-310.pyc +0 -0
  23. lib/python3.10/site-packages/google/auth/__pycache__/identity_pool.cpython-310.pyc +0 -0
  24. lib/python3.10/site-packages/google/auth/__pycache__/impersonated_credentials.cpython-310.pyc +0 -0
  25. lib/python3.10/site-packages/google/auth/__pycache__/jwt.cpython-310.pyc +0 -0
  26. lib/python3.10/site-packages/google/auth/__pycache__/metrics.cpython-310.pyc +0 -0
  27. lib/python3.10/site-packages/google/auth/__pycache__/pluggable.cpython-310.pyc +0 -0
  28. lib/python3.10/site-packages/google/auth/__pycache__/version.cpython-310.pyc +0 -0
  29. lib/python3.10/site-packages/google/auth/compute_engine/__init__.py +22 -0
  30. lib/python3.10/site-packages/google/auth/compute_engine/__pycache__/__init__.cpython-310.pyc +0 -0
  31. lib/python3.10/site-packages/google/auth/compute_engine/__pycache__/_metadata.cpython-310.pyc +0 -0
  32. lib/python3.10/site-packages/google/auth/compute_engine/__pycache__/credentials.cpython-310.pyc +0 -0
  33. lib/python3.10/site-packages/google/auth/crypt/__init__.py +98 -0
  34. lib/python3.10/site-packages/google/auth/crypt/__pycache__/__init__.cpython-310.pyc +0 -0
  35. lib/python3.10/site-packages/google/auth/crypt/__pycache__/_cryptography_rsa.cpython-310.pyc +0 -0
  36. lib/python3.10/site-packages/google/auth/crypt/__pycache__/_helpers.cpython-310.pyc +0 -0
  37. lib/python3.10/site-packages/google/auth/crypt/__pycache__/_python_rsa.cpython-310.pyc +0 -0
  38. lib/python3.10/site-packages/google/auth/crypt/__pycache__/base.cpython-310.pyc +0 -0
  39. lib/python3.10/site-packages/google/auth/crypt/__pycache__/es256.cpython-310.pyc +0 -0
  40. lib/python3.10/site-packages/google/auth/crypt/__pycache__/rsa.cpython-310.pyc +0 -0
  41. lib/python3.10/site-packages/google/auth/crypt/_cryptography_rsa.py +151 -0
  42. lib/python3.10/site-packages/google/auth/crypt/_helpers.py +0 -0
  43. lib/python3.10/site-packages/google/auth/crypt/_python_rsa.py +175 -0
  44. lib/python3.10/site-packages/google/auth/crypt/base.py +127 -0
  45. lib/python3.10/site-packages/google/auth/crypt/es256.py +175 -0
  46. lib/python3.10/site-packages/google/auth/crypt/rsa.py +30 -0
  47. lib/python3.10/site-packages/google/auth/transport/__init__.py +104 -0
  48. lib/python3.10/site-packages/google/auth/transport/__pycache__/__init__.cpython-310.pyc +0 -0
  49. lib/python3.10/site-packages/google/auth/transport/__pycache__/_aiohttp_requests.cpython-310.pyc +0 -0
  50. lib/python3.10/site-packages/google/auth/transport/__pycache__/_custom_tls_signer.cpython-310.pyc +0 -0
lib/python3.10/site-packages/google/auth/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (1.15 kB). View file
 
lib/python3.10/site-packages/google/auth/__pycache__/_cloud_sdk.cpython-310.pyc ADDED
Binary file (3.47 kB). View file
 
lib/python3.10/site-packages/google/auth/__pycache__/_credentials_async.cpython-310.pyc ADDED
Binary file (6.7 kB). View file
 
lib/python3.10/site-packages/google/auth/__pycache__/_credentials_base.cpython-310.pyc ADDED
Binary file (2.61 kB). View file
 
lib/python3.10/site-packages/google/auth/__pycache__/_default.cpython-310.pyc ADDED
Binary file (21.9 kB). View file
 
lib/python3.10/site-packages/google/auth/__pycache__/_default_async.cpython-310.pyc ADDED
Binary file (8.63 kB). View file
 
lib/python3.10/site-packages/google/auth/__pycache__/_exponential_backoff.cpython-310.pyc ADDED
Binary file (4.77 kB). View file
 
lib/python3.10/site-packages/google/auth/__pycache__/_helpers.cpython-310.pyc ADDED
Binary file (14.2 kB). View file
 
lib/python3.10/site-packages/google/auth/__pycache__/_jwt_async.cpython-310.pyc ADDED
Binary file (5.77 kB). View file
 
lib/python3.10/site-packages/google/auth/__pycache__/_oauth2client.cpython-310.pyc ADDED
Binary file (5 kB). View file
 
lib/python3.10/site-packages/google/auth/__pycache__/_refresh_worker.cpython-310.pyc ADDED
Binary file (3.55 kB). View file
 
lib/python3.10/site-packages/google/auth/__pycache__/_service_account_info.cpython-310.pyc ADDED
Binary file (2.4 kB). View file
 
lib/python3.10/site-packages/google/auth/__pycache__/api_key.cpython-310.pyc ADDED
Binary file (2.73 kB). View file
 
lib/python3.10/site-packages/google/auth/__pycache__/app_engine.cpython-310.pyc ADDED
Binary file (5.41 kB). View file
 
lib/python3.10/site-packages/google/auth/__pycache__/aws.cpython-310.pyc ADDED
Binary file (24.9 kB). View file
 
lib/python3.10/site-packages/google/auth/__pycache__/credentials.cpython-310.pyc ADDED
Binary file (18.4 kB). View file
 
lib/python3.10/site-packages/google/auth/__pycache__/downscoped.cpython-310.pyc ADDED
Binary file (19.7 kB). View file
 
lib/python3.10/site-packages/google/auth/__pycache__/environment_vars.cpython-310.pyc ADDED
Binary file (854 Bytes). View file
 
lib/python3.10/site-packages/google/auth/__pycache__/exceptions.cpython-310.pyc ADDED
Binary file (4.42 kB). View file
 
lib/python3.10/site-packages/google/auth/__pycache__/external_account.cpython-310.pyc ADDED
Binary file (19.6 kB). View file
 
lib/python3.10/site-packages/google/auth/__pycache__/external_account_authorized_user.cpython-310.pyc ADDED
Binary file (13.2 kB). View file
 
lib/python3.10/site-packages/google/auth/__pycache__/iam.cpython-310.pyc ADDED
Binary file (4.17 kB). View file
 
lib/python3.10/site-packages/google/auth/__pycache__/identity_pool.cpython-310.pyc ADDED
Binary file (17.2 kB). View file
 
lib/python3.10/site-packages/google/auth/__pycache__/impersonated_credentials.cpython-310.pyc ADDED
Binary file (19.2 kB). View file
 
lib/python3.10/site-packages/google/auth/__pycache__/jwt.cpython-310.pyc ADDED
Binary file (26.1 kB). View file
 
lib/python3.10/site-packages/google/auth/__pycache__/metrics.cpython-310.pyc ADDED
Binary file (3.46 kB). View file
 
lib/python3.10/site-packages/google/auth/__pycache__/pluggable.cpython-310.pyc ADDED
Binary file (12 kB). View file
 
lib/python3.10/site-packages/google/auth/__pycache__/version.cpython-310.pyc ADDED
Binary file (223 Bytes). View file
 
lib/python3.10/site-packages/google/auth/compute_engine/__init__.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2016 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ """Google Compute Engine authentication."""
16
+
17
+ from google.auth.compute_engine._metadata import detect_gce_residency_linux
18
+ from google.auth.compute_engine.credentials import Credentials
19
+ from google.auth.compute_engine.credentials import IDTokenCredentials
20
+
21
+
22
+ __all__ = ["Credentials", "IDTokenCredentials", "detect_gce_residency_linux"]
lib/python3.10/site-packages/google/auth/compute_engine/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (509 Bytes). View file
 
lib/python3.10/site-packages/google/auth/compute_engine/__pycache__/_metadata.cpython-310.pyc ADDED
Binary file (9.63 kB). View file
 
lib/python3.10/site-packages/google/auth/compute_engine/__pycache__/credentials.cpython-310.pyc ADDED
Binary file (14.7 kB). View file
 
lib/python3.10/site-packages/google/auth/crypt/__init__.py ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2016 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ """Cryptography helpers for verifying and signing messages.
16
+
17
+ The simplest way to verify signatures is using :func:`verify_signature`::
18
+
19
+ cert = open('certs.pem').read()
20
+ valid = crypt.verify_signature(message, signature, cert)
21
+
22
+ If you're going to verify many messages with the same certificate, you can use
23
+ :class:`RSAVerifier`::
24
+
25
+ cert = open('certs.pem').read()
26
+ verifier = crypt.RSAVerifier.from_string(cert)
27
+ valid = verifier.verify(message, signature)
28
+
29
+ To sign messages use :class:`RSASigner` with a private key::
30
+
31
+ private_key = open('private_key.pem').read()
32
+ signer = crypt.RSASigner.from_string(private_key)
33
+ signature = signer.sign(message)
34
+
35
+ The code above also works for :class:`ES256Signer` and :class:`ES256Verifier`.
36
+ Note that these two classes are only available if your `cryptography` dependency
37
+ version is at least 1.4.0.
38
+ """
39
+
40
+ from google.auth.crypt import base
41
+ from google.auth.crypt import rsa
42
+
43
+ try:
44
+ from google.auth.crypt import es256
45
+ except ImportError: # pragma: NO COVER
46
+ es256 = None # type: ignore
47
+
48
+ if es256 is not None: # pragma: NO COVER
49
+ __all__ = [
50
+ "ES256Signer",
51
+ "ES256Verifier",
52
+ "RSASigner",
53
+ "RSAVerifier",
54
+ "Signer",
55
+ "Verifier",
56
+ ]
57
+ else: # pragma: NO COVER
58
+ __all__ = ["RSASigner", "RSAVerifier", "Signer", "Verifier"]
59
+
60
+
61
+ # Aliases to maintain the v1.0.0 interface, as the crypt module was split
62
+ # into submodules.
63
+ Signer = base.Signer
64
+ Verifier = base.Verifier
65
+ RSASigner = rsa.RSASigner
66
+ RSAVerifier = rsa.RSAVerifier
67
+
68
+ if es256 is not None: # pragma: NO COVER
69
+ ES256Signer = es256.ES256Signer
70
+ ES256Verifier = es256.ES256Verifier
71
+
72
+
73
+ def verify_signature(message, signature, certs, verifier_cls=rsa.RSAVerifier):
74
+ """Verify an RSA or ECDSA cryptographic signature.
75
+
76
+ Checks that the provided ``signature`` was generated from ``bytes`` using
77
+ the private key associated with the ``cert``.
78
+
79
+ Args:
80
+ message (Union[str, bytes]): The plaintext message.
81
+ signature (Union[str, bytes]): The cryptographic signature to check.
82
+ certs (Union[Sequence, str, bytes]): The certificate or certificates
83
+ to use to check the signature.
84
+ verifier_cls (Optional[~google.auth.crypt.base.Signer]): Which verifier
85
+ class to use for verification. This can be used to select different
86
+ algorithms, such as RSA or ECDSA. Default value is :class:`RSAVerifier`.
87
+
88
+ Returns:
89
+ bool: True if the signature is valid, otherwise False.
90
+ """
91
+ if isinstance(certs, (str, bytes)):
92
+ certs = [certs]
93
+
94
+ for cert in certs:
95
+ verifier = verifier_cls.from_string(cert)
96
+ if verifier.verify(message, signature):
97
+ return True
98
+ return False
lib/python3.10/site-packages/google/auth/crypt/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (2.52 kB). View file
 
lib/python3.10/site-packages/google/auth/crypt/__pycache__/_cryptography_rsa.cpython-310.pyc ADDED
Binary file (5.21 kB). View file
 
lib/python3.10/site-packages/google/auth/crypt/__pycache__/_helpers.cpython-310.pyc ADDED
Binary file (208 Bytes). View file
 
lib/python3.10/site-packages/google/auth/crypt/__pycache__/_python_rsa.cpython-310.pyc ADDED
Binary file (5.82 kB). View file
 
lib/python3.10/site-packages/google/auth/crypt/__pycache__/base.cpython-310.pyc ADDED
Binary file (4.18 kB). View file
 
lib/python3.10/site-packages/google/auth/crypt/__pycache__/es256.cpython-310.pyc ADDED
Binary file (5.72 kB). View file
 
lib/python3.10/site-packages/google/auth/crypt/__pycache__/rsa.cpython-310.pyc ADDED
Binary file (449 Bytes). View file
 
lib/python3.10/site-packages/google/auth/crypt/_cryptography_rsa.py ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2017 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ """RSA verifier and signer that use the ``cryptography`` library.
16
+
17
+ This is a much faster implementation than the default (in
18
+ ``google.auth.crypt._python_rsa``), which depends on the pure-Python
19
+ ``rsa`` library.
20
+ """
21
+
22
+ import cryptography.exceptions
23
+ from cryptography.hazmat import backends
24
+ from cryptography.hazmat.primitives import hashes
25
+ from cryptography.hazmat.primitives import serialization
26
+ from cryptography.hazmat.primitives.asymmetric import padding
27
+ import cryptography.x509
28
+
29
+ from google.auth import _helpers
30
+ from google.auth.crypt import base
31
+
32
+ _CERTIFICATE_MARKER = b"-----BEGIN CERTIFICATE-----"
33
+ _BACKEND = backends.default_backend()
34
+ _PADDING = padding.PKCS1v15()
35
+ _SHA256 = hashes.SHA256()
36
+
37
+
38
+ class RSAVerifier(base.Verifier):
39
+ """Verifies RSA cryptographic signatures using public keys.
40
+
41
+ Args:
42
+ public_key (
43
+ cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey):
44
+ The public key used to verify signatures.
45
+ """
46
+
47
+ def __init__(self, public_key):
48
+ self._pubkey = public_key
49
+
50
+ @_helpers.copy_docstring(base.Verifier)
51
+ def verify(self, message, signature):
52
+ message = _helpers.to_bytes(message)
53
+ try:
54
+ self._pubkey.verify(signature, message, _PADDING, _SHA256)
55
+ return True
56
+ except (ValueError, cryptography.exceptions.InvalidSignature):
57
+ return False
58
+
59
+ @classmethod
60
+ def from_string(cls, public_key):
61
+ """Construct an Verifier instance from a public key or public
62
+ certificate string.
63
+
64
+ Args:
65
+ public_key (Union[str, bytes]): The public key in PEM format or the
66
+ x509 public key certificate.
67
+
68
+ Returns:
69
+ Verifier: The constructed verifier.
70
+
71
+ Raises:
72
+ ValueError: If the public key can't be parsed.
73
+ """
74
+ public_key_data = _helpers.to_bytes(public_key)
75
+
76
+ if _CERTIFICATE_MARKER in public_key_data:
77
+ cert = cryptography.x509.load_pem_x509_certificate(
78
+ public_key_data, _BACKEND
79
+ )
80
+ pubkey = cert.public_key()
81
+
82
+ else:
83
+ pubkey = serialization.load_pem_public_key(public_key_data, _BACKEND)
84
+
85
+ return cls(pubkey)
86
+
87
+
88
+ class RSASigner(base.Signer, base.FromServiceAccountMixin):
89
+ """Signs messages with an RSA private key.
90
+
91
+ Args:
92
+ private_key (
93
+ cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKey):
94
+ The private key to sign with.
95
+ key_id (str): Optional key ID used to identify this private key. This
96
+ can be useful to associate the private key with its associated
97
+ public key or certificate.
98
+ """
99
+
100
+ def __init__(self, private_key, key_id=None):
101
+ self._key = private_key
102
+ self._key_id = key_id
103
+
104
+ @property # type: ignore
105
+ @_helpers.copy_docstring(base.Signer)
106
+ def key_id(self):
107
+ return self._key_id
108
+
109
+ @_helpers.copy_docstring(base.Signer)
110
+ def sign(self, message):
111
+ message = _helpers.to_bytes(message)
112
+ return self._key.sign(message, _PADDING, _SHA256)
113
+
114
+ @classmethod
115
+ def from_string(cls, key, key_id=None):
116
+ """Construct a RSASigner from a private key in PEM format.
117
+
118
+ Args:
119
+ key (Union[bytes, str]): Private key in PEM format.
120
+ key_id (str): An optional key id used to identify the private key.
121
+
122
+ Returns:
123
+ google.auth.crypt._cryptography_rsa.RSASigner: The
124
+ constructed signer.
125
+
126
+ Raises:
127
+ ValueError: If ``key`` is not ``bytes`` or ``str`` (unicode).
128
+ UnicodeDecodeError: If ``key`` is ``bytes`` but cannot be decoded
129
+ into a UTF-8 ``str``.
130
+ ValueError: If ``cryptography`` "Could not deserialize key data."
131
+ """
132
+ key = _helpers.to_bytes(key)
133
+ private_key = serialization.load_pem_private_key(
134
+ key, password=None, backend=_BACKEND
135
+ )
136
+ return cls(private_key, key_id=key_id)
137
+
138
+ def __getstate__(self):
139
+ """Pickle helper that serializes the _key attribute."""
140
+ state = self.__dict__.copy()
141
+ state["_key"] = self._key.private_bytes(
142
+ encoding=serialization.Encoding.PEM,
143
+ format=serialization.PrivateFormat.PKCS8,
144
+ encryption_algorithm=serialization.NoEncryption(),
145
+ )
146
+ return state
147
+
148
+ def __setstate__(self, state):
149
+ """Pickle helper that deserializes the _key attribute."""
150
+ state["_key"] = serialization.load_pem_private_key(state["_key"], None)
151
+ self.__dict__.update(state)
lib/python3.10/site-packages/google/auth/crypt/_helpers.py ADDED
File without changes
lib/python3.10/site-packages/google/auth/crypt/_python_rsa.py ADDED
@@ -0,0 +1,175 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2016 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ """Pure-Python RSA cryptography implementation.
16
+
17
+ Uses the ``rsa``, ``pyasn1`` and ``pyasn1_modules`` packages
18
+ to parse PEM files storing PKCS#1 or PKCS#8 keys as well as
19
+ certificates. There is no support for p12 files.
20
+ """
21
+
22
+ from __future__ import absolute_import
23
+
24
+ import io
25
+
26
+ from pyasn1.codec.der import decoder # type: ignore
27
+ from pyasn1_modules import pem # type: ignore
28
+ from pyasn1_modules.rfc2459 import Certificate # type: ignore
29
+ from pyasn1_modules.rfc5208 import PrivateKeyInfo # type: ignore
30
+ import rsa # type: ignore
31
+
32
+ from google.auth import _helpers
33
+ from google.auth import exceptions
34
+ from google.auth.crypt import base
35
+
36
+ _POW2 = (128, 64, 32, 16, 8, 4, 2, 1)
37
+ _CERTIFICATE_MARKER = b"-----BEGIN CERTIFICATE-----"
38
+ _PKCS1_MARKER = ("-----BEGIN RSA PRIVATE KEY-----", "-----END RSA PRIVATE KEY-----")
39
+ _PKCS8_MARKER = ("-----BEGIN PRIVATE KEY-----", "-----END PRIVATE KEY-----")
40
+ _PKCS8_SPEC = PrivateKeyInfo()
41
+
42
+
43
+ def _bit_list_to_bytes(bit_list):
44
+ """Converts an iterable of 1s and 0s to bytes.
45
+
46
+ Combines the list 8 at a time, treating each group of 8 bits
47
+ as a single byte.
48
+
49
+ Args:
50
+ bit_list (Sequence): Sequence of 1s and 0s.
51
+
52
+ Returns:
53
+ bytes: The decoded bytes.
54
+ """
55
+ num_bits = len(bit_list)
56
+ byte_vals = bytearray()
57
+ for start in range(0, num_bits, 8):
58
+ curr_bits = bit_list[start : start + 8]
59
+ char_val = sum(val * digit for val, digit in zip(_POW2, curr_bits))
60
+ byte_vals.append(char_val)
61
+ return bytes(byte_vals)
62
+
63
+
64
+ class RSAVerifier(base.Verifier):
65
+ """Verifies RSA cryptographic signatures using public keys.
66
+
67
+ Args:
68
+ public_key (rsa.key.PublicKey): The public key used to verify
69
+ signatures.
70
+ """
71
+
72
+ def __init__(self, public_key):
73
+ self._pubkey = public_key
74
+
75
+ @_helpers.copy_docstring(base.Verifier)
76
+ def verify(self, message, signature):
77
+ message = _helpers.to_bytes(message)
78
+ try:
79
+ return rsa.pkcs1.verify(message, signature, self._pubkey)
80
+ except (ValueError, rsa.pkcs1.VerificationError):
81
+ return False
82
+
83
+ @classmethod
84
+ def from_string(cls, public_key):
85
+ """Construct an Verifier instance from a public key or public
86
+ certificate string.
87
+
88
+ Args:
89
+ public_key (Union[str, bytes]): The public key in PEM format or the
90
+ x509 public key certificate.
91
+
92
+ Returns:
93
+ google.auth.crypt._python_rsa.RSAVerifier: The constructed verifier.
94
+
95
+ Raises:
96
+ ValueError: If the public_key can't be parsed.
97
+ """
98
+ public_key = _helpers.to_bytes(public_key)
99
+ is_x509_cert = _CERTIFICATE_MARKER in public_key
100
+
101
+ # If this is a certificate, extract the public key info.
102
+ if is_x509_cert:
103
+ der = rsa.pem.load_pem(public_key, "CERTIFICATE")
104
+ asn1_cert, remaining = decoder.decode(der, asn1Spec=Certificate())
105
+ if remaining != b"":
106
+ raise exceptions.InvalidValue("Unused bytes", remaining)
107
+
108
+ cert_info = asn1_cert["tbsCertificate"]["subjectPublicKeyInfo"]
109
+ key_bytes = _bit_list_to_bytes(cert_info["subjectPublicKey"])
110
+ pubkey = rsa.PublicKey.load_pkcs1(key_bytes, "DER")
111
+ else:
112
+ pubkey = rsa.PublicKey.load_pkcs1(public_key, "PEM")
113
+ return cls(pubkey)
114
+
115
+
116
+ class RSASigner(base.Signer, base.FromServiceAccountMixin):
117
+ """Signs messages with an RSA private key.
118
+
119
+ Args:
120
+ private_key (rsa.key.PrivateKey): The private key to sign with.
121
+ key_id (str): Optional key ID used to identify this private key. This
122
+ can be useful to associate the private key with its associated
123
+ public key or certificate.
124
+ """
125
+
126
+ def __init__(self, private_key, key_id=None):
127
+ self._key = private_key
128
+ self._key_id = key_id
129
+
130
+ @property # type: ignore
131
+ @_helpers.copy_docstring(base.Signer)
132
+ def key_id(self):
133
+ return self._key_id
134
+
135
+ @_helpers.copy_docstring(base.Signer)
136
+ def sign(self, message):
137
+ message = _helpers.to_bytes(message)
138
+ return rsa.pkcs1.sign(message, self._key, "SHA-256")
139
+
140
+ @classmethod
141
+ def from_string(cls, key, key_id=None):
142
+ """Construct an Signer instance from a private key in PEM format.
143
+
144
+ Args:
145
+ key (str): Private key in PEM format.
146
+ key_id (str): An optional key id used to identify the private key.
147
+
148
+ Returns:
149
+ google.auth.crypt.Signer: The constructed signer.
150
+
151
+ Raises:
152
+ ValueError: If the key cannot be parsed as PKCS#1 or PKCS#8 in
153
+ PEM format.
154
+ """
155
+ key = _helpers.from_bytes(key) # PEM expects str in Python 3
156
+ marker_id, key_bytes = pem.readPemBlocksFromFile(
157
+ io.StringIO(key), _PKCS1_MARKER, _PKCS8_MARKER
158
+ )
159
+
160
+ # Key is in pkcs1 format.
161
+ if marker_id == 0:
162
+ private_key = rsa.key.PrivateKey.load_pkcs1(key_bytes, format="DER")
163
+ # Key is in pkcs8.
164
+ elif marker_id == 1:
165
+ key_info, remaining = decoder.decode(key_bytes, asn1Spec=_PKCS8_SPEC)
166
+ if remaining != b"":
167
+ raise exceptions.InvalidValue("Unused bytes", remaining)
168
+ private_key_info = key_info.getComponentByName("privateKey")
169
+ private_key = rsa.key.PrivateKey.load_pkcs1(
170
+ private_key_info.asOctets(), format="DER"
171
+ )
172
+ else:
173
+ raise exceptions.MalformedError("No key could be detected.")
174
+
175
+ return cls(private_key, key_id=key_id)
lib/python3.10/site-packages/google/auth/crypt/base.py ADDED
@@ -0,0 +1,127 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2016 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ """Base classes for cryptographic signers and verifiers."""
16
+
17
+ import abc
18
+ import io
19
+ import json
20
+
21
+ from google.auth import exceptions
22
+
23
+ _JSON_FILE_PRIVATE_KEY = "private_key"
24
+ _JSON_FILE_PRIVATE_KEY_ID = "private_key_id"
25
+
26
+
27
+ class Verifier(metaclass=abc.ABCMeta):
28
+ """Abstract base class for crytographic signature verifiers."""
29
+
30
+ @abc.abstractmethod
31
+ def verify(self, message, signature):
32
+ """Verifies a message against a cryptographic signature.
33
+
34
+ Args:
35
+ message (Union[str, bytes]): The message to verify.
36
+ signature (Union[str, bytes]): The cryptography signature to check.
37
+
38
+ Returns:
39
+ bool: True if message was signed by the private key associated
40
+ with the public key that this object was constructed with.
41
+ """
42
+ # pylint: disable=missing-raises-doc,redundant-returns-doc
43
+ # (pylint doesn't recognize that this is abstract)
44
+ raise NotImplementedError("Verify must be implemented")
45
+
46
+
47
+ class Signer(metaclass=abc.ABCMeta):
48
+ """Abstract base class for cryptographic signers."""
49
+
50
+ @abc.abstractproperty
51
+ def key_id(self):
52
+ """Optional[str]: The key ID used to identify this private key."""
53
+ raise NotImplementedError("Key id must be implemented")
54
+
55
+ @abc.abstractmethod
56
+ def sign(self, message):
57
+ """Signs a message.
58
+
59
+ Args:
60
+ message (Union[str, bytes]): The message to be signed.
61
+
62
+ Returns:
63
+ bytes: The signature of the message.
64
+ """
65
+ # pylint: disable=missing-raises-doc,redundant-returns-doc
66
+ # (pylint doesn't recognize that this is abstract)
67
+ raise NotImplementedError("Sign must be implemented")
68
+
69
+
70
+ class FromServiceAccountMixin(metaclass=abc.ABCMeta):
71
+ """Mix-in to enable factory constructors for a Signer."""
72
+
73
+ @abc.abstractmethod
74
+ def from_string(cls, key, key_id=None):
75
+ """Construct an Signer instance from a private key string.
76
+
77
+ Args:
78
+ key (str): Private key as a string.
79
+ key_id (str): An optional key id used to identify the private key.
80
+
81
+ Returns:
82
+ google.auth.crypt.Signer: The constructed signer.
83
+
84
+ Raises:
85
+ ValueError: If the key cannot be parsed.
86
+ """
87
+ raise NotImplementedError("from_string must be implemented")
88
+
89
+ @classmethod
90
+ def from_service_account_info(cls, info):
91
+ """Creates a Signer instance instance from a dictionary containing
92
+ service account info in Google format.
93
+
94
+ Args:
95
+ info (Mapping[str, str]): The service account info in Google
96
+ format.
97
+
98
+ Returns:
99
+ google.auth.crypt.Signer: The constructed signer.
100
+
101
+ Raises:
102
+ ValueError: If the info is not in the expected format.
103
+ """
104
+ if _JSON_FILE_PRIVATE_KEY not in info:
105
+ raise exceptions.MalformedError(
106
+ "The private_key field was not found in the service account " "info."
107
+ )
108
+
109
+ return cls.from_string(
110
+ info[_JSON_FILE_PRIVATE_KEY], info.get(_JSON_FILE_PRIVATE_KEY_ID)
111
+ )
112
+
113
+ @classmethod
114
+ def from_service_account_file(cls, filename):
115
+ """Creates a Signer instance from a service account .json file
116
+ in Google format.
117
+
118
+ Args:
119
+ filename (str): The path to the service account .json file.
120
+
121
+ Returns:
122
+ google.auth.crypt.Signer: The constructed signer.
123
+ """
124
+ with io.open(filename, "r", encoding="utf-8") as json_file:
125
+ data = json.load(json_file)
126
+
127
+ return cls.from_service_account_info(data)
lib/python3.10/site-packages/google/auth/crypt/es256.py ADDED
@@ -0,0 +1,175 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2017 Google Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ """ECDSA (ES256) verifier and signer that use the ``cryptography`` library.
16
+ """
17
+
18
+ from cryptography import utils # type: ignore
19
+ import cryptography.exceptions
20
+ from cryptography.hazmat import backends
21
+ from cryptography.hazmat.primitives import hashes
22
+ from cryptography.hazmat.primitives import serialization
23
+ from cryptography.hazmat.primitives.asymmetric import ec
24
+ from cryptography.hazmat.primitives.asymmetric import padding
25
+ from cryptography.hazmat.primitives.asymmetric.utils import decode_dss_signature
26
+ from cryptography.hazmat.primitives.asymmetric.utils import encode_dss_signature
27
+ import cryptography.x509
28
+
29
+ from google.auth import _helpers
30
+ from google.auth.crypt import base
31
+
32
+
33
+ _CERTIFICATE_MARKER = b"-----BEGIN CERTIFICATE-----"
34
+ _BACKEND = backends.default_backend()
35
+ _PADDING = padding.PKCS1v15()
36
+
37
+
38
+ class ES256Verifier(base.Verifier):
39
+ """Verifies ECDSA cryptographic signatures using public keys.
40
+
41
+ Args:
42
+ public_key (
43
+ cryptography.hazmat.primitives.asymmetric.ec.ECDSAPublicKey):
44
+ The public key used to verify signatures.
45
+ """
46
+
47
+ def __init__(self, public_key):
48
+ self._pubkey = public_key
49
+
50
+ @_helpers.copy_docstring(base.Verifier)
51
+ def verify(self, message, signature):
52
+ # First convert (r||s) raw signature to ASN1 encoded signature.
53
+ sig_bytes = _helpers.to_bytes(signature)
54
+ if len(sig_bytes) != 64:
55
+ return False
56
+ r = (
57
+ int.from_bytes(sig_bytes[:32], byteorder="big")
58
+ if _helpers.is_python_3()
59
+ else utils.int_from_bytes(sig_bytes[:32], byteorder="big")
60
+ )
61
+ s = (
62
+ int.from_bytes(sig_bytes[32:], byteorder="big")
63
+ if _helpers.is_python_3()
64
+ else utils.int_from_bytes(sig_bytes[32:], byteorder="big")
65
+ )
66
+ asn1_sig = encode_dss_signature(r, s)
67
+
68
+ message = _helpers.to_bytes(message)
69
+ try:
70
+ self._pubkey.verify(asn1_sig, message, ec.ECDSA(hashes.SHA256()))
71
+ return True
72
+ except (ValueError, cryptography.exceptions.InvalidSignature):
73
+ return False
74
+
75
+ @classmethod
76
+ def from_string(cls, public_key):
77
+ """Construct an Verifier instance from a public key or public
78
+ certificate string.
79
+
80
+ Args:
81
+ public_key (Union[str, bytes]): The public key in PEM format or the
82
+ x509 public key certificate.
83
+
84
+ Returns:
85
+ Verifier: The constructed verifier.
86
+
87
+ Raises:
88
+ ValueError: If the public key can't be parsed.
89
+ """
90
+ public_key_data = _helpers.to_bytes(public_key)
91
+
92
+ if _CERTIFICATE_MARKER in public_key_data:
93
+ cert = cryptography.x509.load_pem_x509_certificate(
94
+ public_key_data, _BACKEND
95
+ )
96
+ pubkey = cert.public_key()
97
+
98
+ else:
99
+ pubkey = serialization.load_pem_public_key(public_key_data, _BACKEND)
100
+
101
+ return cls(pubkey)
102
+
103
+
104
+ class ES256Signer(base.Signer, base.FromServiceAccountMixin):
105
+ """Signs messages with an ECDSA private key.
106
+
107
+ Args:
108
+ private_key (
109
+ cryptography.hazmat.primitives.asymmetric.ec.ECDSAPrivateKey):
110
+ The private key to sign with.
111
+ key_id (str): Optional key ID used to identify this private key. This
112
+ can be useful to associate the private key with its associated
113
+ public key or certificate.
114
+ """
115
+
116
+ def __init__(self, private_key, key_id=None):
117
+ self._key = private_key
118
+ self._key_id = key_id
119
+
120
+ @property # type: ignore
121
+ @_helpers.copy_docstring(base.Signer)
122
+ def key_id(self):
123
+ return self._key_id
124
+
125
+ @_helpers.copy_docstring(base.Signer)
126
+ def sign(self, message):
127
+ message = _helpers.to_bytes(message)
128
+ asn1_signature = self._key.sign(message, ec.ECDSA(hashes.SHA256()))
129
+
130
+ # Convert ASN1 encoded signature to (r||s) raw signature.
131
+ (r, s) = decode_dss_signature(asn1_signature)
132
+ return (
133
+ (r.to_bytes(32, byteorder="big") + s.to_bytes(32, byteorder="big"))
134
+ if _helpers.is_python_3()
135
+ else (utils.int_to_bytes(r, 32) + utils.int_to_bytes(s, 32))
136
+ )
137
+
138
+ @classmethod
139
+ def from_string(cls, key, key_id=None):
140
+ """Construct a RSASigner from a private key in PEM format.
141
+
142
+ Args:
143
+ key (Union[bytes, str]): Private key in PEM format.
144
+ key_id (str): An optional key id used to identify the private key.
145
+
146
+ Returns:
147
+ google.auth.crypt._cryptography_rsa.RSASigner: The
148
+ constructed signer.
149
+
150
+ Raises:
151
+ ValueError: If ``key`` is not ``bytes`` or ``str`` (unicode).
152
+ UnicodeDecodeError: If ``key`` is ``bytes`` but cannot be decoded
153
+ into a UTF-8 ``str``.
154
+ ValueError: If ``cryptography`` "Could not deserialize key data."
155
+ """
156
+ key = _helpers.to_bytes(key)
157
+ private_key = serialization.load_pem_private_key(
158
+ key, password=None, backend=_BACKEND
159
+ )
160
+ return cls(private_key, key_id=key_id)
161
+
162
+ def __getstate__(self):
163
+ """Pickle helper that serializes the _key attribute."""
164
+ state = self.__dict__.copy()
165
+ state["_key"] = self._key.private_bytes(
166
+ encoding=serialization.Encoding.PEM,
167
+ format=serialization.PrivateFormat.PKCS8,
168
+ encryption_algorithm=serialization.NoEncryption(),
169
+ )
170
+ return state
171
+
172
+ def __setstate__(self, state):
173
+ """Pickle helper that deserializes the _key attribute."""
174
+ state["_key"] = serialization.load_pem_private_key(state["_key"], None)
175
+ self.__dict__.update(state)
lib/python3.10/site-packages/google/auth/crypt/rsa.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2017 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ """RSA cryptography signer and verifier."""
16
+
17
+
18
+ try:
19
+ # Prefer cryptograph-based RSA implementation.
20
+ from google.auth.crypt import _cryptography_rsa
21
+
22
+ RSASigner = _cryptography_rsa.RSASigner
23
+ RSAVerifier = _cryptography_rsa.RSAVerifier
24
+ except ImportError: # pragma: NO COVER
25
+ # Fallback to pure-python RSA implementation if cryptography is
26
+ # unavailable.
27
+ from google.auth.crypt import _python_rsa
28
+
29
+ RSASigner = _python_rsa.RSASigner # type: ignore
30
+ RSAVerifier = _python_rsa.RSAVerifier # type: ignore
lib/python3.10/site-packages/google/auth/transport/__init__.py ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2016 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ """Transport - HTTP client library support.
16
+
17
+ :mod:`google.auth` is designed to work with various HTTP client libraries such
18
+ as urllib3 and requests. In order to work across these libraries with different
19
+ interfaces some abstraction is needed.
20
+
21
+ This module provides two interfaces that are implemented by transport adapters
22
+ to support HTTP libraries. :class:`Request` defines the interface expected by
23
+ :mod:`google.auth` to make requests. :class:`Response` defines the interface
24
+ for the return value of :class:`Request`.
25
+ """
26
+
27
+ import abc
28
+ import http.client as http_client
29
+
30
+ DEFAULT_RETRYABLE_STATUS_CODES = (
31
+ http_client.INTERNAL_SERVER_ERROR,
32
+ http_client.SERVICE_UNAVAILABLE,
33
+ http_client.GATEWAY_TIMEOUT,
34
+ http_client.REQUEST_TIMEOUT,
35
+ http_client.TOO_MANY_REQUESTS,
36
+ )
37
+ """Sequence[int]: HTTP status codes indicating a request can be retried.
38
+ """
39
+
40
+
41
+ DEFAULT_REFRESH_STATUS_CODES = (http_client.UNAUTHORIZED,)
42
+ """Sequence[int]: Which HTTP status code indicate that credentials should be
43
+ refreshed.
44
+ """
45
+
46
+ DEFAULT_MAX_REFRESH_ATTEMPTS = 2
47
+ """int: How many times to refresh the credentials and retry a request."""
48
+
49
+
50
+ class Response(metaclass=abc.ABCMeta):
51
+ """HTTP Response data."""
52
+
53
+ @abc.abstractproperty
54
+ def status(self):
55
+ """int: The HTTP status code."""
56
+ raise NotImplementedError("status must be implemented.")
57
+
58
+ @abc.abstractproperty
59
+ def headers(self):
60
+ """Mapping[str, str]: The HTTP response headers."""
61
+ raise NotImplementedError("headers must be implemented.")
62
+
63
+ @abc.abstractproperty
64
+ def data(self):
65
+ """bytes: The response body."""
66
+ raise NotImplementedError("data must be implemented.")
67
+
68
+
69
+ class Request(metaclass=abc.ABCMeta):
70
+ """Interface for a callable that makes HTTP requests.
71
+
72
+ Specific transport implementations should provide an implementation of
73
+ this that adapts their specific request / response API.
74
+
75
+ .. automethod:: __call__
76
+ """
77
+
78
+ @abc.abstractmethod
79
+ def __call__(
80
+ self, url, method="GET", body=None, headers=None, timeout=None, **kwargs
81
+ ):
82
+ """Make an HTTP request.
83
+
84
+ Args:
85
+ url (str): The URI to be requested.
86
+ method (str): The HTTP method to use for the request. Defaults
87
+ to 'GET'.
88
+ body (bytes): The payload / body in HTTP request.
89
+ headers (Mapping[str, str]): Request headers.
90
+ timeout (Optional[int]): The number of seconds to wait for a
91
+ response from the server. If not specified or if None, the
92
+ transport-specific default timeout will be used.
93
+ kwargs: Additionally arguments passed on to the transport's
94
+ request method.
95
+
96
+ Returns:
97
+ Response: The HTTP response.
98
+
99
+ Raises:
100
+ google.auth.exceptions.TransportError: If any exception occurred.
101
+ """
102
+ # pylint: disable=redundant-returns-doc, missing-raises-doc
103
+ # (pylint doesn't play well with abstract docstrings.)
104
+ raise NotImplementedError("__call__ must be implemented.")
lib/python3.10/site-packages/google/auth/transport/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (3.28 kB). View file
 
lib/python3.10/site-packages/google/auth/transport/__pycache__/_aiohttp_requests.cpython-310.pyc ADDED
Binary file (12 kB). View file
 
lib/python3.10/site-packages/google/auth/transport/__pycache__/_custom_tls_signer.cpython-310.pyc ADDED
Binary file (6.17 kB). View file