usso 0.8.0__tar.gz → 0.10.0__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: usso
3
- Version: 0.8.0
3
+ Version: 0.10.0
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.8.0"
7
+ version = "0.10.0"
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.8"
@@ -0,0 +1,19 @@
1
+ import base64
2
+ import uuid
3
+
4
+
5
+ def b64_encode_uuid(uuid_str):
6
+ uuid_bytes = uuid.UUID(uuid_str).bytes
7
+ encoded_uuid = base64.urlsafe_b64encode(uuid_bytes).decode()
8
+ return encoded_uuid
9
+
10
+
11
+ def b64_encode_uuid_strip(uuid_str):
12
+ return b64_encode_uuid(uuid_str).rstrip("=")
13
+
14
+
15
+ def b64_decode_uuid(encoded_uuid):
16
+ encoded_uuid += "=" * (4 - len(encoded_uuid) % 4) # Add padding if needed
17
+ decoded_uuid = base64.urlsafe_b64decode(encoded_uuid)
18
+ uuid_obj = uuid.UUID(bytes=decoded_uuid)
19
+ return uuid_obj
@@ -1,9 +1,12 @@
1
+ import uuid
1
2
  from functools import lru_cache
2
3
  from typing import Optional, Tuple
3
4
 
4
5
  import jwt
5
6
  from pydantic import BaseModel
6
7
 
8
+ from . import b64tools
9
+
7
10
 
8
11
  class UserData(BaseModel):
9
12
  user_id: str
@@ -15,6 +18,17 @@ class UserData(BaseModel):
15
18
  data: dict | None = None
16
19
  token: str | None = None
17
20
 
21
+ @property
22
+ def uid(self) -> uuid.UUID:
23
+ user_id = self.user_id
24
+
25
+ if user_id.startswith("u_"):
26
+ user_id = user_id[2:]
27
+ if 22 <= len(user_id) <= 24:
28
+ user_id = b64tools.b64_decode_uuid(user_id)
29
+
30
+ return uuid.UUID(user_id)
31
+
18
32
 
19
33
  def get_authorization_scheme_param(
20
34
  authorization_header_value: Optional[str],
File without changes
File without changes
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: usso
3
- Version: 0.8.0
3
+ Version: 0.10.0
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>
@@ -2,6 +2,7 @@ LICENSE.txt
2
2
  README.md
3
3
  pyproject.toml
4
4
  src/usso/__init__.py
5
+ src/usso/b64tools.py
5
6
  src/usso/core.py
6
7
  src/usso/exceptions.py
7
8
  src/usso/package_data.dat
@@ -1 +0,0 @@
1
- from .core import UserData
@@ -1 +0,0 @@
1
- from .integration import user_data_from_token, jwt_access_security
File without changes
File without changes
File without changes
File without changes
File without changes