usso 0.27.21__py3-none-any.whl → 0.27.22__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/session/async_session.py +7 -5
- usso/session/base_session.py +4 -3
- usso/session/session.py +6 -6
- {usso-0.27.21.dist-info → usso-0.27.22.dist-info}/METADATA +1 -1
- {usso-0.27.21.dist-info → usso-0.27.22.dist-info}/RECORD +9 -9
- {usso-0.27.21.dist-info → usso-0.27.22.dist-info}/LICENSE.txt +0 -0
- {usso-0.27.21.dist-info → usso-0.27.22.dist-info}/WHEEL +0 -0
- {usso-0.27.21.dist-info → usso-0.27.22.dist-info}/entry_points.txt +0 -0
- {usso-0.27.21.dist-info → usso-0.27.22.dist-info}/top_level.txt +0 -0
usso/session/async_session.py
CHANGED
@@ -36,7 +36,9 @@ class AsyncUssoSession(httpx.AsyncClient, BaseUssoSession):
|
|
36
36
|
"""
|
37
37
|
Helper function to prepare headers and parameters for refresh requests.
|
38
38
|
"""
|
39
|
-
headers =
|
39
|
+
headers = (
|
40
|
+
{"x-api-key": self.usso_admin_api_key} if self.usso_admin_api_key else {}
|
41
|
+
)
|
40
42
|
params = {"user_id": self.user_id} if self.user_id else {}
|
41
43
|
return headers, params
|
42
44
|
|
@@ -54,12 +56,12 @@ class AsyncUssoSession(httpx.AsyncClient, BaseUssoSession):
|
|
54
56
|
|
55
57
|
def _refresh_sync(self) -> dict:
|
56
58
|
assert (
|
57
|
-
self.refresh_token or self.
|
59
|
+
self.refresh_token or self.usso_admin_api_key
|
58
60
|
), "refresh_token or usso_api_key is required"
|
59
61
|
|
60
62
|
headers, params = self._prepare_refresh_request()
|
61
63
|
|
62
|
-
if self.
|
64
|
+
if self.usso_admin_api_key and not self.refresh_token:
|
63
65
|
response = httpx.get(
|
64
66
|
f"{self.usso_refresh_url}/api", headers=headers, params=params
|
65
67
|
)
|
@@ -72,12 +74,12 @@ class AsyncUssoSession(httpx.AsyncClient, BaseUssoSession):
|
|
72
74
|
|
73
75
|
async def _refresh(self) -> dict:
|
74
76
|
assert (
|
75
|
-
self.refresh_token or self.
|
77
|
+
self.refresh_token or self.usso_admin_api_key
|
76
78
|
), "refresh_token or usso_api_key is required"
|
77
79
|
|
78
80
|
headers, params = self._prepare_refresh_request()
|
79
81
|
|
80
|
-
if self.
|
82
|
+
if self.usso_admin_api_key and not self.refresh_token:
|
81
83
|
response = await self.get(
|
82
84
|
f"{self.usso_refresh_url}/api", headers=headers, params=params
|
83
85
|
)
|
usso/session/base_session.py
CHANGED
@@ -2,9 +2,7 @@ import os
|
|
2
2
|
from urllib.parse import urlparse
|
3
3
|
|
4
4
|
from usso.core import is_expired
|
5
|
-
from typing import Optional
|
6
|
-
import inspect
|
7
|
-
|
5
|
+
from typing import Optional
|
8
6
|
|
9
7
|
|
10
8
|
class BaseUssoSession:
|
@@ -61,7 +59,10 @@ class BaseUssoSession:
|
|
61
59
|
|
62
60
|
if api_key:
|
63
61
|
self.api_key = api_key
|
62
|
+
self.headers = self.headers or {}
|
64
63
|
self.headers.update({"x-api-key": api_key})
|
64
|
+
else:
|
65
|
+
self.api_key = None
|
65
66
|
|
66
67
|
if not usso_base_url:
|
67
68
|
url_parts = urlparse(usso_refresh_url)
|
usso/session/session.py
CHANGED
@@ -36,15 +36,15 @@ class UssoSession(httpx.Client, BaseUssoSession):
|
|
36
36
|
user_id=user_id,
|
37
37
|
client=client,
|
38
38
|
)
|
39
|
-
if not
|
39
|
+
if not self.api_key:
|
40
40
|
self._refresh()
|
41
41
|
|
42
42
|
def _refresh_api(self):
|
43
|
-
assert self.
|
43
|
+
assert self.usso_admin_api_key, "usso_api_key is required"
|
44
44
|
params = {"user_id": self.user_id} if self.user_id else {}
|
45
45
|
response = httpx.get(
|
46
46
|
f"{self.usso_refresh_url}/api",
|
47
|
-
headers={"x-api-key": self.
|
47
|
+
headers={"x-api-key": self.usso_admin_api_key},
|
48
48
|
params=params,
|
49
49
|
)
|
50
50
|
response.raise_for_status()
|
@@ -53,10 +53,10 @@ class UssoSession(httpx.Client, BaseUssoSession):
|
|
53
53
|
|
54
54
|
def _refresh(self):
|
55
55
|
assert (
|
56
|
-
self.refresh_token or self.
|
56
|
+
self.refresh_token or self.usso_admin_api_key
|
57
57
|
), "refresh_token or usso_api_key is required"
|
58
58
|
|
59
|
-
if self.
|
59
|
+
if self.usso_admin_api_key and not self.refresh_token:
|
60
60
|
self._refresh_api()
|
61
61
|
|
62
62
|
response = httpx.post(
|
@@ -68,7 +68,7 @@ class UssoSession(httpx.Client, BaseUssoSession):
|
|
68
68
|
return response.json()
|
69
69
|
|
70
70
|
def get_session(self):
|
71
|
-
if
|
71
|
+
if self.api_key:
|
72
72
|
return self
|
73
73
|
|
74
74
|
if not self.access_token or is_expired(self.access_token):
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: usso
|
3
|
-
Version: 0.27.
|
3
|
+
Version: 0.27.22
|
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>
|
@@ -11,12 +11,12 @@ usso/django/middleware.py,sha256=EEEpHvMQ6QiWw2HY8zQ2Aec0RCATcLWsCKeyiPWJKio,324
|
|
11
11
|
usso/fastapi/__init__.py,sha256=0EcdOzb4f3yu9nILIdGWnlyUz-0VaVX2az1e3f2BusI,201
|
12
12
|
usso/fastapi/integration.py,sha256=IonxxNj_B9sG2j672rIzE047qo972vk7ch4-eGENp3Q,2638
|
13
13
|
usso/session/__init__.py,sha256=tE4qWUdSI7iN_pywm47Mg8NKOTBa2nCNwCy3wCZWRmU,124
|
14
|
-
usso/session/async_session.py,sha256=
|
15
|
-
usso/session/base_session.py,sha256=
|
16
|
-
usso/session/session.py,sha256=
|
17
|
-
usso-0.27.
|
18
|
-
usso-0.27.
|
19
|
-
usso-0.27.
|
20
|
-
usso-0.27.
|
21
|
-
usso-0.27.
|
22
|
-
usso-0.27.
|
14
|
+
usso/session/async_session.py,sha256=bOWUeBpE2reDdK9zXrD4ZrZrRWlEOyyafWgPcLg2WLY,3638
|
15
|
+
usso/session/base_session.py,sha256=1Ad6LbX8IsCPTeEIopnYwybrkPkN5zgGUobv8VHcipA,3430
|
16
|
+
usso/session/session.py,sha256=T3v3lGvLxs4Yi-zZRzdKHLxEo2rtVewcLk-1V6Y44Jk,2569
|
17
|
+
usso-0.27.22.dist-info/LICENSE.txt,sha256=ceC9ZJOV9H6CtQDcYmHOS46NA3dHJ_WD4J9blH513pc,1081
|
18
|
+
usso-0.27.22.dist-info/METADATA,sha256=_di-fqd1GQaRLFMQHK2aVHv6xApGgeOEPlYYjqoI15E,4580
|
19
|
+
usso-0.27.22.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
20
|
+
usso-0.27.22.dist-info/entry_points.txt,sha256=4Zgpm5ELaAWPf0jPGJFz1_X69H7un8ycT3WdGoJ0Vvk,35
|
21
|
+
usso-0.27.22.dist-info/top_level.txt,sha256=g9Jf6h1Oyidh0vPiFni7UHInTJjSvu6cUalpLTIvthg,5
|
22
|
+
usso-0.27.22.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|