Skip to content
This repository was archived by the owner on Mar 6, 2026. It is now read-only.

Commit e6e9c26

Browse files
Merge branch 'add_cryptography_dependency' into remove_rsa_3
2 parents 6efed1d + ba8b25e commit e6e9c26

15 files changed

Lines changed: 129 additions & 129 deletions

File tree

.github/workflows/unittest.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
runs-on: ubuntu-22.04
2727
strategy:
2828
matrix:
29-
python: ['3.8']
29+
python: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13', '3.14']
3030
steps:
3131
- name: Checkout
3232
uses: actions/checkout@v4

google/auth/__init__.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ class Python37DeprecationWarning(DeprecationWarning): # pragma: NO COVER
4242

4343

4444
# Raise warnings for deprecated versions
45-
eol_message = """
46-
You are using a Python version {} past its end of life. Google will update
47-
google-auth with critical bug fixes on a best-effort basis, but not
48-
with any other fixes or features. Please upgrade your Python version,
49-
and then update google-auth.
50-
"""
45+
eol_message = (
46+
"You are using a Python version {} past its end of life. Google will update "
47+
"google-auth with critical bug fixes on a best-effort basis, but not "
48+
"with any other fixes or features. Please upgrade your Python version, "
49+
"and then update google-auth."
50+
)
5151
if sys.version_info.major == 3 and sys.version_info.minor == 8: # pragma: NO COVER
5252
warnings.warn(eol_message.format("3.8"), FutureWarning)
5353
elif sys.version_info.major == 3 and sys.version_info.minor == 9: # pragma: NO COVER

google/auth/aws.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -530,9 +530,10 @@ def _get_metadata_security_credentials(
530530
google.auth.exceptions.RefreshError: If an error occurs while
531531
retrieving the AWS security credentials.
532532
"""
533-
headers = {"Content-Type": "application/json"}
534533
if imdsv2_session_token is not None:
535-
headers["X-aws-ec2-metadata-token"] = imdsv2_session_token
534+
headers = {"X-aws-ec2-metadata-token": imdsv2_session_token}
535+
else:
536+
headers = None
536537

537538
response = request(
538539
url="{}/{}".format(self._security_credentials_url, role_name),

google/auth/crypt/__init__.py

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -38,35 +38,14 @@
3838
"""
3939

4040
from google.auth.crypt import base
41+
from google.auth.crypt import es
42+
from google.auth.crypt import es256
4143
from google.auth.crypt import rsa
4244

43-
# google.auth.crypt.es depends on the crytpography module which may not be
44-
# successfully imported depending on the system.
45-
try:
46-
from google.auth.crypt import es
47-
from google.auth.crypt import es256
48-
except ImportError: # pragma: NO COVER
49-
es = None # type: ignore
50-
es256 = None # type: ignore
51-
52-
if es is not None and es256 is not None: # pragma: NO COVER
53-
__all__ = [
54-
"EsSigner",
55-
"EsVerifier",
56-
"ES256Signer",
57-
"ES256Verifier",
58-
"RSASigner",
59-
"RSAVerifier",
60-
"Signer",
61-
"Verifier",
62-
]
63-
64-
EsSigner = es.EsSigner
65-
EsVerifier = es.EsVerifier
66-
ES256Signer = es256.ES256Signer
67-
ES256Verifier = es256.ES256Verifier
68-
else: # pragma: NO COVER
69-
__all__ = ["RSASigner", "RSAVerifier", "Signer", "Verifier"]
45+
EsSigner = es.EsSigner
46+
EsVerifier = es.EsVerifier
47+
ES256Signer = es256.ES256Signer
48+
ES256Verifier = es256.ES256Verifier
7049

7150

7251
# Aliases to maintain the v1.0.0 interface, as the crypt module was split
@@ -103,3 +82,15 @@ class to use for verification. This can be used to select different
10382
if verifier.verify(message, signature):
10483
return True
10584
return False
85+
86+
87+
__all__ = [
88+
"EsSigner",
89+
"EsVerifier",
90+
"ES256Signer",
91+
"ES256Verifier",
92+
"RSASigner",
93+
"RSAVerifier",
94+
"Signer",
95+
"Verifier",
96+
]

google/auth/crypt/es.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,15 @@ def verify(self, message: bytes, signature: bytes) -> bool:
102102

103103
@classmethod
104104
def from_string(cls, public_key: Union[str, bytes]) -> "EsVerifier":
105-
"""Construct an Verifier instance from a public key or public
105+
"""Construct a Verifier instance from a public key or public
106106
certificate string.
107107
108108
Args:
109109
public_key (Union[str, bytes]): The public key in PEM format or the
110110
x509 public key certificate.
111111
112112
Returns:
113-
Verifier: The constructed verifier.
113+
google.auth.crypt.Verifier: The constructed verifier.
114114
115115
Raises:
116116
ValueError: If the public key can't be parsed.

google/auth/crypt/rsa.py

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,8 @@
3232
class RSAVerifier(base.Verifier):
3333
"""Verifies RSA cryptographic signatures using public keys.
3434
35-
Requires installation of `cryptography` optional dependency.
36-
37-
.. deprecated::
38-
The `rsa` library has been archived. Please migrate to
39-
`cryptography` for public keys.
40-
4135
Args:
42-
public_key (Union[rsa.key.PublicKey, cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey]):
36+
public_key (Union["rsa.key.PublicKey", cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey]):
4337
The public key used to verify signatures.
4438
Raises:
4539
ImportError: if called with an rsa.key.PublicKey, when the rsa library is not installed
@@ -84,14 +78,8 @@ def from_string(cls, public_key):
8478
class RSASigner(base.Signer, base.FromServiceAccountMixin):
8579
"""Signs messages with an RSA private key.
8680
87-
Requires installation of `cryptography` optional dependency.
88-
89-
.. deprecated::
90-
The `rsa` library has been archived. Please migrate to
91-
`cryptography` for public keys.
92-
9381
Args:
94-
private_key (Union[rsa.key.PrivateKey, cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKey]):
82+
private_key (Union["rsa.key.PrivateKey", cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKey]):
9583
The private key to sign with.
9684
key_id (str): Optional key ID used to identify this private key. This
9785
can be useful to associate the private key with its associated

google/oauth2/__init__.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ class Python37DeprecationWarning(DeprecationWarning): # pragma: NO COVER
2828

2929

3030
# Raise warnings for deprecated versions
31-
eol_message = """
32-
You are using a Python version {} past its end of life. Google will update
33-
google-auth with critical bug fixes on a best-effort basis, but not
34-
with any other fixes or features. Please upgrade your Python version,
35-
and then update google-auth.
36-
"""
31+
eol_message = (
32+
"You are using a Python version {} past its end of life. Google will update "
33+
"google-auth with critical bug fixes on a best-effort basis, but not "
34+
"with any other fixes or features. Please upgrade your Python version, "
35+
"and then update google-auth."
36+
)
3737
if sys.version_info.major == 3 and sys.version_info.minor == 8: # pragma: NO COVER
3838
warnings.warn(eol_message.format("3.8"), FutureWarning)
3939
elif sys.version_info.major == 3 and sys.version_info.minor == 9: # pragma: NO COVER

noxfile.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,7 @@
5151
"lint",
5252
"blacken",
5353
"mypy",
54-
"unit-3.9",
55-
"unit-3.10",
56-
"unit-3.11",
57-
"unit-3.12",
58-
"unit-3.13",
59-
"unit-3.14",
6054
# cover must be last to avoid error `No data to report`
61-
"cover",
6255
"docs",
6356
]
6457

samples/cloud-client/snippets/requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
google-cloud-compute==1.41.0
2-
google-cloud-storage==3.7.0
1+
google-cloud-compute==1.42.0
2+
google-cloud-storage==3.8.0
33
google-auth==2.47.0
44
pytest===8.4.2; python_version == '3.9'
55
pytest==9.0.2; python_version > '3.9'

setup.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,15 @@
1818
from setuptools import find_namespace_packages
1919
from setuptools import setup
2020

21+
cryptography_base_require = [
22+
"cryptography >= 38.0.3",
23+
]
2124

2225
DEPENDENCIES = (
2326
"pyasn1-modules>=0.2.1",
24-
"cryptography >= 38.0.3",
27+
cryptography_base_require,
2528
)
2629

27-
# Note: cryptography was made into a required dependency. Extra is kept for backwards compatibility
28-
cryptography_extra_require = [
29-
"cryptography >= 38.0.3",
30-
]
31-
3230
requests_extra_require = ["requests >= 2.20.0, < 3.0.0"]
3331

3432
aiohttp_extra_require = ["aiohttp >= 3.6.2, < 4.0.0", *requests_extra_require]
@@ -37,8 +35,8 @@
3735

3836
reauth_extra_require = ["pyu2f>=0.1.5"]
3937

40-
# TODO(https://github.com/googleapis/google-auth-library-python/issues/1738): Add bounds for cryptography and pyopenssl dependencies.
41-
enterprise_cert_extra_require = ["cryptography", "pyopenssl"]
38+
# TODO(https://github.com/googleapis/google-auth-library-python/issues/1738): Add bounds for pyopenssl dependency.
39+
enterprise_cert_extra_require = ["pyopenssl"]
4240

4341
pyopenssl_extra_require = ["pyopenssl>=20.0.0"]
4442

@@ -78,7 +76,8 @@
7876
]
7977

8078
extras = {
81-
"cryptography": cryptography_extra_require,
79+
# Note: cryptography was made into a required dependency. Extra is kept for backwards compatibility
80+
"cryptography": cryptography_base_require,
8281
"aiohttp": aiohttp_extra_require,
8382
"enterprise_cert": enterprise_cert_extra_require,
8483
"pyopenssl": pyopenssl_extra_require,

0 commit comments

Comments
 (0)