Skip to content

Commit 57110ff

Browse files
authored
Raise minimum msal version to 1.6.0 (Azure#14992)
1 parent 8c28ff3 commit 57110ff

File tree

5 files changed

+13
-7
lines changed

5 files changed

+13
-7
lines changed

sdk/identity/azure-identity/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
provided, the credential will authenticate users to an Azure development
1111
application.
1212
([#14354](https://github.com/Azure/azure-sdk-for-python/issues/14354))
13+
- Raised minimum msal version to 1.6.0
1314

1415
### Fixed
1516
- `ManagedIdentityCredential` uses the API version supported by Azure Functions

sdk/identity/azure-identity/azure/identity/_credentials/certificate.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from typing import TYPE_CHECKING
77

88
from cryptography import x509
9-
from cryptography.hazmat.primitives import hashes, serialization
9+
from cryptography.hazmat.primitives import hashes
1010
from cryptography.hazmat.backends import default_backend
1111
import six
1212

@@ -55,9 +55,10 @@ def __init__(self, tenant_id, client_id, certificate_path, **kwargs):
5555
cert = x509.load_pem_x509_certificate(pem_bytes, default_backend())
5656
fingerprint = cert.fingerprint(hashes.SHA1()) # nosec
5757

58-
# TODO: msal doesn't formally support passwords (but soon will); the below depends on an implementation detail
59-
private_key = serialization.load_pem_private_key(pem_bytes, password=password, backend=default_backend())
60-
client_credential = {"private_key": private_key, "thumbprint": hexlify(fingerprint).decode("utf-8")}
58+
client_credential = {"private_key": pem_bytes, "thumbprint": hexlify(fingerprint).decode("utf-8")}
59+
if password:
60+
client_credential["passphrase"] = password
61+
6162
if kwargs.pop("send_certificate_chain", False):
6263
try:
6364
# the JWT needs the whole chain but load_pem_x509_certificate deserializes only the signing cert

sdk/identity/azure-identity/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
install_requires=[
7474
"azure-core<2.0.0,>=1.0.0",
7575
"cryptography>=2.1.4",
76-
"msal<1.6.0,>=1.3.0",
76+
"msal<2.0.0,>=1.6.0",
7777
"msal-extensions~=0.3.0",
7878
"six>=1.6",
7979
],

sdk/identity/azure-identity/tests/test_certificate_credential.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,11 @@
3636
CERT_PATH = os.path.join(os.path.dirname(__file__), "certificate.pem")
3737
CERT_WITH_PASSWORD_PATH = os.path.join(os.path.dirname(__file__), "certificate-with-password.pem")
3838
CERT_PASSWORD = "password"
39-
BOTH_CERTS = ((CERT_PATH, None), (CERT_WITH_PASSWORD_PATH, CERT_PASSWORD))
39+
BOTH_CERTS = (
40+
(CERT_PATH, None),
41+
(CERT_WITH_PASSWORD_PATH, CERT_PASSWORD), # credential should accept passwords as str or bytes
42+
(CERT_WITH_PASSWORD_PATH, CERT_PASSWORD.encode("utf-8")),
43+
)
4044

4145

4246
def test_no_scopes():

shared_requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ futures
102102
mock
103103
typing
104104
typing-extensions
105-
msal<1.6.0,>=1.3.0
105+
msal<2.0.0,>=1.6.0
106106
msal-extensions~=0.3.0
107107
msrest>=0.5.0
108108
msrestazure<2.0.0,>=0.4.32

0 commit comments

Comments
 (0)