usso 0.28.22__tar.gz → 0.28.24__tar.gz

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.
Files changed (35) hide show
  1. {usso-0.28.22/src/usso.egg-info → usso-0.28.24}/PKG-INFO +1 -1
  2. {usso-0.28.22 → usso-0.28.24}/pyproject.toml +1 -1
  3. {usso-0.28.22 → usso-0.28.24}/pytest.ini +0 -2
  4. {usso-0.28.22 → usso-0.28.24}/src/usso/__init__.py +3 -2
  5. {usso-0.28.22/src/usso/auth → usso-0.28.24/src/usso}/api_key.py +8 -3
  6. {usso-0.28.22/src/usso/auth → usso-0.28.24/src/usso}/client.py +2 -2
  7. {usso-0.28.22/src/usso/auth → usso-0.28.24/src/usso}/config.py +2 -2
  8. {usso-0.28.22 → usso-0.28.24}/src/usso/exceptions.py +17 -1
  9. {usso-0.28.22 → usso-0.28.24}/src/usso/integrations/fastapi/dependency.py +3 -6
  10. {usso-0.28.22 → usso-0.28.24/src/usso.egg-info}/PKG-INFO +1 -1
  11. {usso-0.28.22 → usso-0.28.24}/src/usso.egg-info/SOURCES.txt +5 -7
  12. {usso-0.28.22 → usso-0.28.24}/tests/test_authorization.py +1 -1
  13. usso-0.28.22/src/usso/auth/__init__.py +0 -9
  14. usso-0.28.22/src/usso/utils/method_utils.py +0 -12
  15. {usso-0.28.22 → usso-0.28.24}/LICENSE.txt +0 -0
  16. {usso-0.28.22 → usso-0.28.24}/MANIFEST.in +0 -0
  17. {usso-0.28.22 → usso-0.28.24}/README.md +0 -0
  18. {usso-0.28.22 → usso-0.28.24}/setup.cfg +0 -0
  19. {usso-0.28.22/src/usso/auth → usso-0.28.24/src/usso}/authorization.py +0 -0
  20. {usso-0.28.22 → usso-0.28.24}/src/usso/integrations/django/__init__.py +0 -0
  21. {usso-0.28.22 → usso-0.28.24}/src/usso/integrations/django/middleware.py +0 -0
  22. {usso-0.28.22 → usso-0.28.24}/src/usso/integrations/fastapi/__init__.py +0 -0
  23. {usso-0.28.22 → usso-0.28.24}/src/usso/integrations/fastapi/handler.py +0 -0
  24. {usso-0.28.22 → usso-0.28.24}/src/usso/session/__init__.py +0 -0
  25. {usso-0.28.22 → usso-0.28.24}/src/usso/session/async_session.py +0 -0
  26. {usso-0.28.22 → usso-0.28.24}/src/usso/session/base_session.py +0 -0
  27. {usso-0.28.22 → usso-0.28.24}/src/usso/session/session.py +0 -0
  28. {usso-0.28.22/src/usso/models → usso-0.28.24/src/usso}/user.py +0 -0
  29. {usso-0.28.22 → usso-0.28.24}/src/usso/utils/__init__.py +0 -0
  30. {usso-0.28.22 → usso-0.28.24}/src/usso/utils/string_utils.py +0 -0
  31. {usso-0.28.22 → usso-0.28.24}/src/usso.egg-info/dependency_links.txt +0 -0
  32. {usso-0.28.22 → usso-0.28.24}/src/usso.egg-info/entry_points.txt +0 -0
  33. {usso-0.28.22 → usso-0.28.24}/src/usso.egg-info/requires.txt +0 -0
  34. {usso-0.28.22 → usso-0.28.24}/src/usso.egg-info/top_level.txt +0 -0
  35. {usso-0.28.22 → usso-0.28.24}/tests/test_fastapi.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: usso
3
- Version: 0.28.22
3
+ Version: 0.28.24
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>
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "usso"
7
- version = "0.28.22"
7
+ version = "0.28.24"
8
8
  description = "A plug-and-play client for integrating universal single sign-on (SSO) with Python frameworks, enabling secure and seamless authentication across microservices."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"
@@ -8,8 +8,6 @@ asyncio_default_fixture_loop_scope = session
8
8
 
9
9
  addopts =
10
10
  --cov=src/usso/integrations/fastapi
11
- --cov=src/usso/auth
12
- --cov=src/usso/models
13
11
  ; --cov=src/usso/session
14
12
  --cov=src/usso/utils
15
13
  ; --cov=src/usso
@@ -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
 
@@ -1,10 +1,11 @@
1
1
  import logging
2
+ import os
2
3
 
3
4
  import cachetools.func
4
5
  import httpx
5
6
 
6
- from ..exceptions import USSOException
7
- from ..models.user import UserData
7
+ from .exceptions import USSOException
8
+ from .user import UserData
8
9
 
9
10
  logger = logging.getLogger("usso")
10
11
 
@@ -33,7 +34,11 @@ def fetch_api_key_data(api_key_verify_url: str, api_key: str):
33
34
  USSOException: If the API key is invalid or verification fails
34
35
  """
35
36
  try:
36
- response = httpx.post(api_key_verify_url, json={"api_key": api_key})
37
+ response = httpx.post(
38
+ api_key_verify_url,
39
+ json={"api_key": api_key},
40
+ proxy=os.getenv("PROXY"),
41
+ )
37
42
  response.raise_for_status()
38
43
  return UserData(**response.json())
39
44
  except Exception as e:
@@ -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):
@@ -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.24
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>
@@ -4,30 +4,28 @@ README.md
4
4
  pyproject.toml
5
5
  pytest.ini
6
6
  src/usso/__init__.py
7
+ src/usso/api_key.py
8
+ src/usso/authorization.py
9
+ src/usso/client.py
10
+ src/usso/config.py
7
11
  src/usso/exceptions.py
12
+ src/usso/user.py
8
13
  src/usso.egg-info/PKG-INFO
9
14
  src/usso.egg-info/SOURCES.txt
10
15
  src/usso.egg-info/dependency_links.txt
11
16
  src/usso.egg-info/entry_points.txt
12
17
  src/usso.egg-info/requires.txt
13
18
  src/usso.egg-info/top_level.txt
14
- src/usso/auth/__init__.py
15
- src/usso/auth/api_key.py
16
- src/usso/auth/authorization.py
17
- src/usso/auth/client.py
18
- src/usso/auth/config.py
19
19
  src/usso/integrations/django/__init__.py
20
20
  src/usso/integrations/django/middleware.py
21
21
  src/usso/integrations/fastapi/__init__.py
22
22
  src/usso/integrations/fastapi/dependency.py
23
23
  src/usso/integrations/fastapi/handler.py
24
- src/usso/models/user.py
25
24
  src/usso/session/__init__.py
26
25
  src/usso/session/async_session.py
27
26
  src/usso/session/base_session.py
28
27
  src/usso/session/session.py
29
28
  src/usso/utils/__init__.py
30
- src/usso/utils/method_utils.py
31
29
  src/usso/utils/string_utils.py
32
30
  tests/test_authorization.py
33
31
  tests/test_fastapi.py
@@ -1,6 +1,6 @@
1
1
  import pytest
2
2
 
3
- from src.usso.auth.authorization import (
3
+ from src.usso.authorization import (
4
4
  check_access,
5
5
  has_subset_scope,
6
6
  is_path_match,
@@ -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
File without changes
File without changes
File without changes
File without changes
File without changes