usso 0.25.1__py3-none-any.whl → 0.25.3__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.
usso/core.py CHANGED
@@ -7,7 +7,6 @@ from functools import lru_cache
7
7
  import cachetools.func
8
8
  import jwt
9
9
  from pydantic import BaseModel, model_validator
10
- from singleton import Singleton
11
10
 
12
11
  from . import b64tools
13
12
  from .exceptions import USSOException
@@ -61,6 +60,7 @@ def get_authorization_scheme_param(
61
60
  def decode_token(key, token: str, algorithms=["RS256"], **kwargs) -> dict:
62
61
  try:
63
62
  decoded = jwt.decode(token, key, algorithms=algorithms)
63
+ decoded["data"] = decoded
64
64
  decoded["token"] = token
65
65
  return UserData(**decoded)
66
66
  except jwt.exceptions.ExpiredSignatureError:
@@ -188,7 +188,16 @@ class Usso:
188
188
  exp = None
189
189
  for jwk_config in self.jwt_configs:
190
190
  try:
191
- return jwk_config.decode(token)
191
+ user_data = jwk_config.decode(token)
192
+ if user_data.token_type.lower() != kwargs.get("token_type", "access"):
193
+ raise USSOException(
194
+ status_code=401,
195
+ error="invalid_token_type",
196
+ message="Token type must be 'access'",
197
+ )
198
+
199
+ return user_data
200
+
192
201
  except USSOException as e:
193
202
  exp = e
194
203
 
@@ -5,7 +5,7 @@ from starlette.status import HTTP_401_UNAUTHORIZED
5
5
 
6
6
  from usso.exceptions import USSOException
7
7
 
8
- from ..core import UserData, Usso
8
+ from ..core import UserData, Usso, get_authorization_scheme_param
9
9
 
10
10
  logger = logging.getLogger("usso")
11
11
 
@@ -15,7 +15,7 @@ def get_request_token(request: Request | WebSocket) -> UserData | None:
15
15
  token = None
16
16
 
17
17
  if authorization:
18
- scheme, credentials = Usso().get_authorization_scheme_param(authorization)
18
+ scheme, credentials = get_authorization_scheme_param(authorization)
19
19
  if scheme.lower() == "bearer":
20
20
  token = credentials
21
21
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: usso
3
- Version: 0.25.1
3
+ Version: 0.25.3
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>
@@ -45,7 +45,6 @@ License-File: LICENSE.txt
45
45
  Requires-Dist: pydantic >=2
46
46
  Requires-Dist: requests >=2.26.0
47
47
  Requires-Dist: pyjwt[crypto]
48
- Requires-Dist: singleton-package
49
48
  Requires-Dist: cachetools
50
49
  Provides-Extra: dev
51
50
  Requires-Dist: check-manifest ; extra == 'dev'
@@ -3,16 +3,16 @@ usso/api.py,sha256=xlDq2nZNpq3mhAvqIbGEfANHNjJpPquSeULBfS7iMJw,5094
3
3
  usso/async_api.py,sha256=rb-Xh5oudmZrPYM_iH_B75b5Z0Fvi1V1uurdcKE51w0,5551
4
4
  usso/async_session.py,sha256=nFIrtV3Tp0H-s2ZkMLU9_fVSeVGq1EtY1bGT_XOS5Vw,4336
5
5
  usso/b64tools.py,sha256=HGQ0E59vzjrQo2-4jrcY03ebtTaYwTtCZ7KgJaEmxO0,610
6
- usso/core.py,sha256=vrGpfueuX3CwkBdGj9ze-BPuI61TOlLPsCqHiKOQnFY,6510
6
+ usso/core.py,sha256=I2Mxwfa3SAAIGMNCYhu7q9ejaS219Lz9O7h6zVBZYCI,6858
7
7
  usso/exceptions.py,sha256=hawOAuVbvQtjgRfwp1KFZ4SmV7fh720y5Gom9JVA8W8,504
8
8
  usso/session.py,sha256=Lky2O8FGbOMJFOMxxdE0rhpgwWKThGQfr-X9YQsFpLk,2358
9
9
  usso/django/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
10
  usso/django/middleware.py,sha256=EEEpHvMQ6QiWw2HY8zQ2Aec0RCATcLWsCKeyiPWJKio,3245
11
11
  usso/fastapi/__init__.py,sha256=0EcdOzb4f3yu9nILIdGWnlyUz-0VaVX2az1e3f2BusI,201
12
- usso/fastapi/integration.py,sha256=LNKd_KStKr5CBj_CUfwkrgtiY5R8nBL61FVBWcIrhQE,1667
13
- usso-0.25.1.dist-info/LICENSE.txt,sha256=ceC9ZJOV9H6CtQDcYmHOS46NA3dHJ_WD4J9blH513pc,1081
14
- usso-0.25.1.dist-info/METADATA,sha256=z1rpx_Pqk64o-Bpi6q38jpHDYZDGr9jiYha05I1jxBg,4227
15
- usso-0.25.1.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
16
- usso-0.25.1.dist-info/entry_points.txt,sha256=4Zgpm5ELaAWPf0jPGJFz1_X69H7un8ycT3WdGoJ0Vvk,35
17
- usso-0.25.1.dist-info/top_level.txt,sha256=g9Jf6h1Oyidh0vPiFni7UHInTJjSvu6cUalpLTIvthg,5
18
- usso-0.25.1.dist-info/RECORD,,
12
+ usso/fastapi/integration.py,sha256=tvf_oD7x6y0gVmW_BwJkYI-UO5LIMpWxJsh2IPBftlM,1692
13
+ usso-0.25.3.dist-info/LICENSE.txt,sha256=ceC9ZJOV9H6CtQDcYmHOS46NA3dHJ_WD4J9blH513pc,1081
14
+ usso-0.25.3.dist-info/METADATA,sha256=cfBtCQXLYFdZIri1-KHwzoTuYgxQM2HdS6qTAOYW2wc,4194
15
+ usso-0.25.3.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
16
+ usso-0.25.3.dist-info/entry_points.txt,sha256=4Zgpm5ELaAWPf0jPGJFz1_X69H7un8ycT3WdGoJ0Vvk,35
17
+ usso-0.25.3.dist-info/top_level.txt,sha256=g9Jf6h1Oyidh0vPiFni7UHInTJjSvu6cUalpLTIvthg,5
18
+ usso-0.25.3.dist-info/RECORD,,
File without changes