Skip to content

Commit 45dba05

Browse files
Merge pull request #357 from supertokens/fix/remove-cryptography-constraints
fix: Remove constraints on cryptography lib dependency
2 parents 4300657 + cfc0c3c commit 45dba05

File tree

5 files changed

+73
-6
lines changed

5 files changed

+73
-6
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88

99
## [unreleased]
1010

11+
## [0.14.5] - 2023-06-21
12+
13+
### Changes and fixes
14+
15+
- Remove constraints on `cryptograpy` dependency version and let `pyjwt` library handle it
16+
1117
## [0.14.4] - 2023-06-14
1218

1319
### Changes and fixes

setup.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070

7171
setup(
7272
name="supertokens_python",
73-
version="0.14.4",
73+
version="0.14.5",
7474
author="SuperTokens",
7575
license="Apache 2.0",
7676
author_email="[email protected]",
@@ -99,14 +99,15 @@
9999
],
100100
keywords="",
101101
install_requires=[
102-
"PyJWT>=2.6.0 ,<3.0.0",
102+
# [crypto] ensures that it installs the `cryptography` library as well
103+
# based on constraints specified in https://github.com/jpadilla/pyjwt/blob/master/setup.cfg#L50
104+
"PyJWT[crypto]>=2.6.0 ,<3.0.0",
103105
"httpx>=0.15.0 ,<0.24.0",
104106
"pycryptodome==3.10.*",
105107
"tldextract==3.1.0",
106108
"asgiref>=3.4.1,<4",
107109
"typing_extensions>=4.1.1,<5.0.0",
108110
"Deprecated==1.2.13",
109-
"cryptography>=35.0,<37.0",
110111
"phonenumbers==8.12.48",
111112
"twilio==7.9.1",
112113
"aiosmtplib==1.1.6",

supertokens_python/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from __future__ import annotations
1515

1616
SUPPORTED_CDI_VERSIONS = ["2.21"]
17-
VERSION = "0.14.4"
17+
VERSION = "0.14.5"
1818
TELEMETRY = "/telemetry"
1919
USER_COUNT = "/users/count"
2020
USER_DELETE = "/user/remove"

supertokens_python/recipe/thirdparty/providers/apple.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@
1616
from re import sub
1717
from time import time
1818
from typing import TYPE_CHECKING, Any, Callable, Dict, List, Union
19-
20-
from cryptography.hazmat.primitives.asymmetric.rsa import RSAPublicKey
2119
from httpx import AsyncClient
2220
from jwt import decode, encode
21+
22+
# You must have cryptography library installed for these imports to work:
2323
from jwt.algorithms import RSAAlgorithm
24+
from cryptography.hazmat.primitives.asymmetric.rsa import RSAPublicKey
25+
2426
from supertokens_python.recipe.thirdparty.api.implementation import (
2527
get_actual_client_id_from_development_client_id,
2628
)

tests/thirdparty/test_thirdparty.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import respx
2+
import httpx
3+
14
from pytest import fixture, mark
25
from fastapi import FastAPI
36
from supertokens_python.framework.fastapi import get_middleware
@@ -21,6 +24,8 @@
2124

2225
pytestmark = mark.asyncio
2326

27+
respx_mock = respx.MockRouter
28+
2429

2530
@fixture(scope="function")
2631
async def fastapi_client():
@@ -64,3 +69,56 @@ async def test_thirdpary_parsing_works(fastapi_client: TestClient):
6469
res.content
6570
== b'<html><head><script>window.location.replace("http://supertokens.io/auth/callback/apple?state=afc596274293e1587315c&code=c7685e261f98e4b3b94e34b3a69ff9cf4.0.rvxt.eE8rO__6hGoqaX1B7ODPmA");</script></head></html>'
6671
)
72+
73+
74+
async def test_apple_provider_can_fetch_keys():
75+
from supertokens_python.recipe.thirdparty.providers.apple import Apple
76+
from cryptography.hazmat.primitives.asymmetric.rsa import RSAPublicKey
77+
78+
def api_side_effect(_: httpx.Request):
79+
return httpx.Response(
80+
200,
81+
json={
82+
"keys": [
83+
{
84+
"kty": "RSA",
85+
"kid": "W6WcOKB",
86+
"use": "sig",
87+
"alg": "RS256",
88+
"n": "2Zc5d0-zkZ5AKmtYTvxHc3vRc41YfbklflxG9SWsg5qXUxvfgpktGAcxXLFAd9Uglzow9ezvmTGce5d3DhAYKwHAEPT9hbaMDj7DfmEwuNO8UahfnBkBXsCoUaL3QITF5_DAPsZroTqs7tkQQZ7qPkQXCSu2aosgOJmaoKQgwcOdjD0D49ne2B_dkxBcNCcJT9pTSWJ8NfGycjWAQsvC8CGstH8oKwhC5raDcc2IGXMOQC7Qr75d6J5Q24CePHj_JD7zjbwYy9KNH8wyr829eO_G4OEUW50FAN6HKtvjhJIguMl_1BLZ93z2KJyxExiNTZBUBQbbgCNBfzTv7JrxMw",
89+
"e": "AQAB",
90+
},
91+
{
92+
"kty": "RSA",
93+
"kid": "fh6Bs8C",
94+
"use": "sig",
95+
"alg": "RS256",
96+
"n": "u704gotMSZc6CSSVNCZ1d0S9dZKwO2BVzfdTKYz8wSNm7R_KIufOQf3ru7Pph1FjW6gQ8zgvhnv4IebkGWsZJlodduTC7c0sRb5PZpEyM6PtO8FPHowaracJJsK1f6_rSLstLdWbSDXeSq7vBvDu3Q31RaoV_0YlEzQwPsbCvD45oVy5Vo5oBePUm4cqi6T3cZ-10gr9QJCVwvx7KiQsttp0kUkHM94PlxbG_HAWlEZjvAlxfEDc-_xZQwC6fVjfazs3j1b2DZWsGmBRdx1snO75nM7hpyRRQB4jVejW9TuZDtPtsNadXTr9I5NjxPdIYMORj9XKEh44Z73yfv0gtw",
97+
"e": "AQAB",
98+
},
99+
{
100+
"kty": "RSA",
101+
"kid": "YuyXoY",
102+
"use": "sig",
103+
"alg": "RS256",
104+
"n": "1JiU4l3YCeT4o0gVmxGTEK1IXR-Ghdg5Bzka12tzmtdCxU00ChH66aV-4HRBjF1t95IsaeHeDFRgmF0lJbTDTqa6_VZo2hc0zTiUAsGLacN6slePvDcR1IMucQGtPP5tGhIbU-HKabsKOFdD4VQ5PCXifjpN9R-1qOR571BxCAl4u1kUUIePAAJcBcqGRFSI_I1j_jbN3gflK_8ZNmgnPrXA0kZXzj1I7ZHgekGbZoxmDrzYm2zmja1MsE5A_JX7itBYnlR41LOtvLRCNtw7K3EFlbfB6hkPL-Swk5XNGbWZdTROmaTNzJhV-lWT0gGm6V1qWAK2qOZoIDa_3Ud0Gw",
105+
"e": "AQAB",
106+
},
107+
]
108+
},
109+
)
110+
111+
with respx_mock(assert_all_mocked=False) as mocker:
112+
mocked_route = mocker.get("https://appleid.apple.com/auth/keys").mock(
113+
side_effect=api_side_effect
114+
)
115+
116+
apple = Apple(
117+
"client-id", "client-key-id", "client-private-key", "client-team-id"
118+
)
119+
# pylint: disable=protected-access
120+
keys = await apple._fetch_apple_public_keys() # type: ignore
121+
122+
assert mocked_route.call_count == 1
123+
assert len(keys) == 3
124+
assert isinstance(keys[0], RSAPublicKey)

0 commit comments

Comments
 (0)