usso 0.28.22__py3-none-any.whl → 0.28.23__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/__init__.py CHANGED
@@ -5,9 +5,10 @@ with Python frameworks, enabling secure and seamless authentication
5
5
  across microservices.
6
6
  """
7
7
 
8
- from .auth import APIHeaderConfig, AuthConfig, HeaderConfig, UssoAuth
8
+ from .client import AuthConfig, UssoAuth
9
+ from .config import APIHeaderConfig, HeaderConfig
9
10
  from .exceptions import USSOException
10
- from .models.user import UserData
11
+ from .user import UserData
11
12
 
12
13
  __version__ = "0.28.0"
13
14
 
@@ -3,8 +3,8 @@ import logging
3
3
  import cachetools.func
4
4
  import httpx
5
5
 
6
- from ..exceptions import USSOException
7
- from ..models.user import UserData
6
+ from .exceptions import USSOException
7
+ from .user import UserData
8
8
 
9
9
  logger = logging.getLogger("usso")
10
10
 
@@ -3,10 +3,10 @@ import logging
3
3
  import usso_jwt.exceptions
4
4
  import usso_jwt.schemas
5
5
 
6
- from ..exceptions import _handle_exception
7
- from ..models.user import UserData
8
6
  from .api_key import fetch_api_key_data
9
7
  from .config import AuthConfig, AvailableJwtConfigs
8
+ from .exceptions import _handle_exception
9
+ from .user import UserData
10
10
 
11
11
  logger = logging.getLogger("usso")
12
12
 
@@ -4,8 +4,8 @@ from typing import Any, Literal, Union
4
4
  import usso_jwt.config
5
5
  from pydantic import BaseModel, model_validator
6
6
 
7
- from ..models.user import UserData
8
- from ..utils.string_utils import get_authorization_scheme_param
7
+ from .user import UserData
8
+ from .utils.string_utils import get_authorization_scheme_param
9
9
 
10
10
 
11
11
  class HeaderConfig(BaseModel):
usso/exceptions.py CHANGED
@@ -8,11 +8,14 @@ error_messages = {
8
8
  "expired_signature": "Unauthorized. The JWT is expired.",
9
9
  "unauthorized": "Unauthorized",
10
10
  "invalid_token_type": "Unauthorized. Token type must be 'access'",
11
+ "permission_denied": "Permission denied",
11
12
  }
12
13
 
13
14
 
14
15
  class USSOException(Exception):
15
- def __init__(self, status_code: int, error: str, message: str = None):
16
+ def __init__(
17
+ self, status_code: int, error: str, message: dict | None = None
18
+ ):
16
19
  self.status_code = status_code
17
20
  self.error = error
18
21
  self.message = message
@@ -21,6 +24,19 @@ class USSOException(Exception):
21
24
  super().__init__(message)
22
25
 
23
26
 
27
+ class PermissionDenied(USSOException):
28
+ def __init__(
29
+ self,
30
+ error: str = "permission_denied",
31
+ message: dict = None,
32
+ detail: str = None,
33
+ **kwargs,
34
+ ):
35
+ super().__init__(
36
+ 403, error=error, message=message, detail=detail, **kwargs
37
+ )
38
+
39
+
24
40
  def _handle_exception(error_type: str, **kwargs):
25
41
  """Handle JWT-related exceptions."""
26
42
  if kwargs.get("raise_exception", True):
@@ -2,11 +2,10 @@ import logging
2
2
 
3
3
  from fastapi import Request, WebSocket
4
4
 
5
- from ...auth import UssoAuth
6
- from ...auth.config import AuthConfig, AvailableJwtConfigs
5
+ from ...client import UssoAuth
6
+ from ...config import AuthConfig, AvailableJwtConfigs
7
7
  from ...exceptions import _handle_exception
8
- from ...models.user import UserData
9
- from ...utils.method_utils import instance_method
8
+ from ...user import UserData
10
9
 
11
10
  logger = logging.getLogger("usso")
12
11
 
@@ -28,7 +27,6 @@ class USSOAuthentication(UssoAuth):
28
27
  def __call__(self, request: Request) -> UserData:
29
28
  return self.usso_access_security(request)
30
29
 
31
- @instance_method
32
30
  def get_request_jwt(self, request: Request | WebSocket) -> str | None:
33
31
  for jwt_config in self.jwt_configs:
34
32
  token = jwt_config.get_jwt(request)
@@ -36,7 +34,6 @@ class USSOAuthentication(UssoAuth):
36
34
  return token
37
35
  return None
38
36
 
39
- @instance_method
40
37
  def get_request_api_key(self, request: Request | WebSocket) -> str | None:
41
38
  for jwt_config in self.jwt_configs:
42
39
  token = jwt_config.get_api_key(request)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: usso
3
- Version: 0.28.22
3
+ Version: 0.28.23
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>
@@ -0,0 +1,24 @@
1
+ usso/__init__.py,sha256=ot4Q5ouLGe505DGFAxQP4p4yZLLaBLqbHmCF1OvHG1M,585
2
+ usso/api_key.py,sha256=AF7NnBkBow65Ar7w0krepdePpmfaxTz1lvpYhWT0kWM,1153
3
+ usso/authorization.py,sha256=a71VKLfjAZXXGGx1x5eAhNKVdeKQxd-bvOgL-wocgPY,6970
4
+ usso/client.py,sha256=9YTyvro3oz24Pr3i1Dit2R2dpIPsGsuIOol66-8VEyI,2636
5
+ usso/config.py,sha256=7GDAh-yHGYppfkhvrwJykhwJp4HH8P_qPAoGcK8_PZQ,3741
6
+ usso/exceptions.py,sha256=ggYczQ2eGUH9nBxRYVmOk-6IRSwY8NgEKjMPcE0E5YM,1385
7
+ usso/user.py,sha256=YD109KyK0W7LWIH-bXYgtJ53b7Ipb9tLLhwXvwQWyrs,3759
8
+ usso/integrations/django/__init__.py,sha256=dKpbffHS5ouGtW6ooI2ivzjPmH_1rOBny85htR-KqrY,97
9
+ usso/integrations/django/middleware.py,sha256=AZKYZ4UPNmyxcD3ANgp0y_fdrFvVQdHBqyYxo5XhQUs,3445
10
+ usso/integrations/fastapi/__init__.py,sha256=ohToiqutHu3Okr8naunssDkamj1OdiG4OpPdBW0rt7U,204
11
+ usso/integrations/fastapi/dependency.py,sha256=Ik1x1tP1QiZ2czr6CYD0gS9Q3P4eUD35gQEANYuESII,2699
12
+ usso/integrations/fastapi/handler.py,sha256=MNDoBYdySumFsBgVw-xir3jXXH63KehFXKCh-pNnNZQ,386
13
+ usso/session/__init__.py,sha256=tE4qWUdSI7iN_pywm47Mg8NKOTBa2nCNwCy3wCZWRmU,124
14
+ usso/session/async_session.py,sha256=eQQh2DXiaHdballRjePa8GSI9GmGsxNDU7vTfwh8mRQ,3971
15
+ usso/session/base_session.py,sha256=O3tEltMhlwkEz1GGbjE4iXPwSlLaUW2juUt9RDSLrHI,2559
16
+ usso/session/session.py,sha256=briCgDMoF-b59H6Aie_Lmjy4qnPBBSmKnVhAwef34F0,1637
17
+ usso/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
+ usso/utils/string_utils.py,sha256=7tziAa2Cwa7xhwM_NF4DSY3BHoqVaWgJ21VuV8LvhrY,253
19
+ usso-0.28.23.dist-info/licenses/LICENSE.txt,sha256=ceC9ZJOV9H6CtQDcYmHOS46NA3dHJ_WD4J9blH513pc,1081
20
+ usso-0.28.23.dist-info/METADATA,sha256=knrRsdnXNCbvLNfHSTPFdhinvZfXaYGwp3KeqaUmXnA,5061
21
+ usso-0.28.23.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
22
+ usso-0.28.23.dist-info/entry_points.txt,sha256=4Zgpm5ELaAWPf0jPGJFz1_X69H7un8ycT3WdGoJ0Vvk,35
23
+ usso-0.28.23.dist-info/top_level.txt,sha256=g9Jf6h1Oyidh0vPiFni7UHInTJjSvu6cUalpLTIvthg,5
24
+ usso-0.28.23.dist-info/RECORD,,
usso/auth/__init__.py DELETED
@@ -1,9 +0,0 @@
1
- """USSO Authentication Module.
2
-
3
- This module provides the core authentication functionality for USSO.
4
- """
5
-
6
- from .client import UssoAuth
7
- from .config import APIHeaderConfig, AuthConfig, HeaderConfig
8
-
9
- __all__ = ["UssoAuth", "AuthConfig", "HeaderConfig", "APIHeaderConfig"]
@@ -1,12 +0,0 @@
1
- class instance_method:
2
- def __init__(self, func):
3
- self.func = func
4
-
5
- def __get__(self, instance, owner):
6
- def wrapper(*args, **kwargs):
7
- if instance is not None:
8
- return self.func(instance, *args, **kwargs)
9
- else:
10
- return self.func(owner(), *args, **kwargs)
11
-
12
- return wrapper
@@ -1,26 +0,0 @@
1
- usso/__init__.py,sha256=t3tYcw4qtGFpk7iakXTqEj5RlzIc8D2fs0I3FZcOmGs,571
2
- usso/exceptions.py,sha256=cBzmMCwpNQKMjCUXO3bCcFwZJQQvbvJ5RxTH987ZlCI,1012
3
- usso/auth/__init__.py,sha256=Dthv-iZTgsHTGcJrkJsnAtDCbRR5dNCx0Ut7MufoAXY,270
4
- usso/auth/api_key.py,sha256=EIW9yCOu52EzF9I16yOmBHtIJQAXZ6YhMwJUsBtuWVA,1162
5
- usso/auth/authorization.py,sha256=a71VKLfjAZXXGGx1x5eAhNKVdeKQxd-bvOgL-wocgPY,6970
6
- usso/auth/client.py,sha256=WFB7I9_fzr_P-oK_elaiCe5EIZZ9kY_LkkJls6BGWZk,2645
7
- usso/auth/config.py,sha256=SQMr6Y0zJFA9jvx8UKKv6PPJ0GVBzlwKXfAhwQn2fjU,3750
8
- usso/integrations/django/__init__.py,sha256=dKpbffHS5ouGtW6ooI2ivzjPmH_1rOBny85htR-KqrY,97
9
- usso/integrations/django/middleware.py,sha256=AZKYZ4UPNmyxcD3ANgp0y_fdrFvVQdHBqyYxo5XhQUs,3445
10
- usso/integrations/fastapi/__init__.py,sha256=ohToiqutHu3Okr8naunssDkamj1OdiG4OpPdBW0rt7U,204
11
- usso/integrations/fastapi/dependency.py,sha256=Cq-rkCrmNIC8OT1OkdMxfIEkmQkl_pwqV7N7CiNnDSA,2801
12
- usso/integrations/fastapi/handler.py,sha256=MNDoBYdySumFsBgVw-xir3jXXH63KehFXKCh-pNnNZQ,386
13
- usso/models/user.py,sha256=YD109KyK0W7LWIH-bXYgtJ53b7Ipb9tLLhwXvwQWyrs,3759
14
- usso/session/__init__.py,sha256=tE4qWUdSI7iN_pywm47Mg8NKOTBa2nCNwCy3wCZWRmU,124
15
- usso/session/async_session.py,sha256=eQQh2DXiaHdballRjePa8GSI9GmGsxNDU7vTfwh8mRQ,3971
16
- usso/session/base_session.py,sha256=O3tEltMhlwkEz1GGbjE4iXPwSlLaUW2juUt9RDSLrHI,2559
17
- usso/session/session.py,sha256=briCgDMoF-b59H6Aie_Lmjy4qnPBBSmKnVhAwef34F0,1637
18
- usso/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
19
- usso/utils/method_utils.py,sha256=1NMN4le04PWXDSJZK-nf7q2IFqOMkwYcCnslFXAzlH8,355
20
- usso/utils/string_utils.py,sha256=7tziAa2Cwa7xhwM_NF4DSY3BHoqVaWgJ21VuV8LvhrY,253
21
- usso-0.28.22.dist-info/licenses/LICENSE.txt,sha256=ceC9ZJOV9H6CtQDcYmHOS46NA3dHJ_WD4J9blH513pc,1081
22
- usso-0.28.22.dist-info/METADATA,sha256=qkMvwYVGxju0Tmb0WUhys3lEiPIV27hhhskCXixYjlg,5061
23
- usso-0.28.22.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
24
- usso-0.28.22.dist-info/entry_points.txt,sha256=4Zgpm5ELaAWPf0jPGJFz1_X69H7un8ycT3WdGoJ0Vvk,35
25
- usso-0.28.22.dist-info/top_level.txt,sha256=g9Jf6h1Oyidh0vPiFni7UHInTJjSvu6cUalpLTIvthg,5
26
- usso-0.28.22.dist-info/RECORD,,
File without changes
File without changes
File without changes