usso 0.28.5__py3-none-any.whl → 0.28.7__py3-none-any.whl

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.
@@ -1,8 +1,8 @@
1
1
  import os
2
2
 
3
3
  import httpx
4
+ from usso_jwt.schemas import JWT, JWTConfig
4
5
 
5
- from ..core import is_expired
6
6
  from .base_session import BaseUssoSession
7
7
 
8
8
 
@@ -49,9 +49,15 @@ class AsyncUssoSession(httpx.AsyncClient, BaseUssoSession):
49
49
  Helper function to process the response from refresh requests.
50
50
  """
51
51
  response.raise_for_status()
52
- data = response.json()
53
- self.access_token = data.get("access_token")
54
- self._refresh_token = data.get("token", {}).get("refresh_token")
52
+ data: dict[str, str | dict[str, str]] = response.json()
53
+ self.access_token = JWT(
54
+ token=data.get("access_token"),
55
+ config=JWTConfig(jwk_url=f"{self.usso_url}/website/jwks.json"),
56
+ )
57
+ self._refresh_token = JWT(
58
+ token=data.get("token", {}).get("refresh_token"),
59
+ config=JWTConfig(jwk_url=f"{self.usso_url}/website/jwks.json"),
60
+ )
55
61
  if self.access_token:
56
62
  self.headers.update({
57
63
  "Authorization": f"Bearer {self.access_token}"
@@ -98,7 +104,7 @@ class AsyncUssoSession(httpx.AsyncClient, BaseUssoSession):
98
104
  if hasattr(self, "api_key") and self.api_key:
99
105
  return self
100
106
 
101
- if not self.access_token or is_expired(self.access_token):
107
+ if not self.access_token or self.access_token.is_temporally_valid():
102
108
  await self._refresh()
103
109
  return self
104
110
 
usso/session/session.py CHANGED
@@ -1,8 +1,7 @@
1
1
  import os
2
2
 
3
3
  import httpx
4
-
5
- from usso.core import is_expired
4
+ from usso_jwt.schemas import JWT, JWTConfig
6
5
 
7
6
  from .base_session import BaseUssoSession
8
7
 
@@ -37,7 +36,10 @@ class UssoSession(httpx.Client, BaseUssoSession):
37
36
  json={"refresh_token": f"{self.refresh_token}"},
38
37
  )
39
38
  response.raise_for_status()
40
- self.access_token = response.json().get("access_token")
39
+ self.access_token = JWT(
40
+ token=response.json().get("access_token"),
41
+ config=JWTConfig(jwk_url=f"{self.usso_url}/website/jwks.json"),
42
+ )
41
43
  self.headers.update({"Authorization": f"Bearer {self.access_token}"})
42
44
  return response.json()
43
45
 
@@ -45,7 +47,7 @@ class UssoSession(httpx.Client, BaseUssoSession):
45
47
  if self.api_key:
46
48
  return self
47
49
 
48
- if not self.access_token or is_expired(self.access_token):
50
+ if not self.access_token or self.access_token.is_temporally_valid():
49
51
  self._refresh()
50
52
  return self
51
53
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: usso
3
- Version: 0.28.5
3
+ Version: 0.28.7
4
4
  Summary: A plug-and-play client for integrating universal single sign-on (SSO) with Python frameworks, enabling secure and seamless authentication across microservices.
5
5
  Author-email: Mahdi Kiani <mahdikiany@gmail.com>
6
6
  Maintainer-email: Mahdi Kiani <mahdikiany@gmail.com>
@@ -28,7 +28,7 @@ Requires-Dist: cachetools
28
28
  Requires-Dist: singleton_package
29
29
  Requires-Dist: json-advanced
30
30
  Requires-Dist: httpx
31
- Requires-Dist: usso-jwt>=0.1.13
31
+ Requires-Dist: usso-jwt>=0.1.16
32
32
  Provides-Extra: fastapi
33
33
  Requires-Dist: fastapi>=0.65.0; extra == "fastapi"
34
34
  Requires-Dist: uvicorn[standard]>=0.13.0; extra == "fastapi"
@@ -11,15 +11,15 @@ usso/integrations/fastapi/dependency.py,sha256=9CaRSvCNbrSQr7EQd6SEs7HhxULWvXLkE
11
11
  usso/integrations/fastapi/handler.py,sha256=MNDoBYdySumFsBgVw-xir3jXXH63KehFXKCh-pNnNZQ,386
12
12
  usso/models/user.py,sha256=P9UOIuv0wMFJ-AGeMT0enEiYkGHW5Pmg8Adc8DZPH7U,3668
13
13
  usso/session/__init__.py,sha256=tE4qWUdSI7iN_pywm47Mg8NKOTBa2nCNwCy3wCZWRmU,124
14
- usso/session/async_session.py,sha256=7OKvFnJQaHnLjeQKSW6bltl0KcQGzOvUje-bJKbxFZY,3692
14
+ usso/session/async_session.py,sha256=QQamIOZZD0eXXkIt8LZVUgjKFTFYnsxWI_HGj2VOMM8,3969
15
15
  usso/session/base_session.py,sha256=Z-Uwcwb0xX6Uo7OVd6ejYz7aMiDWrj5KGein7WWJCo0,2530
16
- usso/session/session.py,sha256=B29Srxoq7webDvmfmfTeeh5JjtLSHvJijM2WCEZOh-8,1506
16
+ usso/session/session.py,sha256=a8iy7lI3cvi7NKi6V1PKfCZ2nLrGTS5sM6Kbu30tN7k,1636
17
17
  usso/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
18
  usso/utils/method_utils.py,sha256=1NMN4le04PWXDSJZK-nf7q2IFqOMkwYcCnslFXAzlH8,355
19
19
  usso/utils/string_utils.py,sha256=7tziAa2Cwa7xhwM_NF4DSY3BHoqVaWgJ21VuV8LvhrY,253
20
- usso-0.28.5.dist-info/licenses/LICENSE.txt,sha256=ceC9ZJOV9H6CtQDcYmHOS46NA3dHJ_WD4J9blH513pc,1081
21
- usso-0.28.5.dist-info/METADATA,sha256=OWk_eQPsFsX4Z1LikDAWt7X7kjiOJs7uF6LcxrGBD2A,4846
22
- usso-0.28.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
23
- usso-0.28.5.dist-info/entry_points.txt,sha256=4Zgpm5ELaAWPf0jPGJFz1_X69H7un8ycT3WdGoJ0Vvk,35
24
- usso-0.28.5.dist-info/top_level.txt,sha256=g9Jf6h1Oyidh0vPiFni7UHInTJjSvu6cUalpLTIvthg,5
25
- usso-0.28.5.dist-info/RECORD,,
20
+ usso-0.28.7.dist-info/licenses/LICENSE.txt,sha256=ceC9ZJOV9H6CtQDcYmHOS46NA3dHJ_WD4J9blH513pc,1081
21
+ usso-0.28.7.dist-info/METADATA,sha256=WNUccObeMC2zgkCCc4gTUeN0WizQINqKj9SBaxXSWy8,4846
22
+ usso-0.28.7.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
23
+ usso-0.28.7.dist-info/entry_points.txt,sha256=4Zgpm5ELaAWPf0jPGJFz1_X69H7un8ycT3WdGoJ0Vvk,35
24
+ usso-0.28.7.dist-info/top_level.txt,sha256=g9Jf6h1Oyidh0vPiFni7UHInTJjSvu6cUalpLTIvthg,5
25
+ usso-0.28.7.dist-info/RECORD,,
File without changes