usso 0.25.3__py3-none-any.whl → 0.25.4__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 +15 -7
- usso/fastapi/integration.py +8 -6
- {usso-0.25.3.dist-info → usso-0.25.4.dist-info}/METADATA +1 -1
- {usso-0.25.3.dist-info → usso-0.25.4.dist-info}/RECORD +8 -8
- {usso-0.25.3.dist-info → usso-0.25.4.dist-info}/LICENSE.txt +0 -0
- {usso-0.25.3.dist-info → usso-0.25.4.dist-info}/WHEEL +0 -0
- {usso-0.25.3.dist-info → usso-0.25.4.dist-info}/entry_points.txt +0 -0
- {usso-0.25.3.dist-info → usso-0.25.4.dist-info}/top_level.txt +0 -0
usso/core.py
CHANGED
@@ -147,23 +147,31 @@ class Usso:
|
|
147
147
|
def __init__(
|
148
148
|
self,
|
149
149
|
*,
|
150
|
-
jwt_config: str | dict | JWTConfig | None = None,
|
151
|
-
|
150
|
+
jwt_config: str | dict | JWTConfig | list[str] | list[dict] | list[JWTConfig] | None = None,
|
151
|
+
jwk_url: str | None = None,
|
152
|
+
secret: str | None = None,
|
152
153
|
):
|
153
|
-
if jwt_config is None
|
154
|
+
if jwt_config is None:
|
154
155
|
jwt_config = os.getenv("USSO_JWT_CONFIG")
|
155
156
|
|
156
|
-
if jwt_config is None
|
157
|
-
jwk_url = os.getenv("USSO_JWK_URL") or os.getenv("USSO_JWKS_URL")
|
157
|
+
if jwt_config is None:
|
158
158
|
if not jwk_url:
|
159
|
+
jwk_url = os.getenv("USSO_JWK_URL") or os.getenv("USSO_JWKS_URL")
|
160
|
+
if jwk_url:
|
159
161
|
self.jwt_configs = [JWTConfig(jwk_url=jwk_url)]
|
160
162
|
return
|
163
|
+
|
164
|
+
if not secret:
|
165
|
+
secret = os.getenv("USSO_SECRET")
|
166
|
+
if secret:
|
167
|
+
self.jwt_configs = [JWTConfig(secret=secret)]
|
168
|
+
return
|
161
169
|
|
162
170
|
raise ValueError(
|
163
171
|
"\n".join(
|
164
172
|
[
|
165
|
-
"
|
166
|
-
"or set the environment variable USSO_JWT_CONFIG or USSO_JWK_URL",
|
173
|
+
"jwt_config or jwk_url or secret must be provided",
|
174
|
+
"or set the environment variable USSO_JWT_CONFIG or USSO_JWK_URL or USSO_SECRET",
|
167
175
|
]
|
168
176
|
)
|
169
177
|
)
|
usso/fastapi/integration.py
CHANGED
@@ -27,33 +27,35 @@ def get_request_token(request: Request | WebSocket) -> UserData | None:
|
|
27
27
|
return token
|
28
28
|
|
29
29
|
|
30
|
-
def jwt_access_security_None(request: Request) -> UserData | None:
|
30
|
+
def jwt_access_security_None(request: Request, jwt_config = None) -> UserData | None:
|
31
31
|
"""Return the user associated with a token value."""
|
32
32
|
token = get_request_token(request)
|
33
33
|
if not token:
|
34
34
|
return None
|
35
|
-
return Usso().user_data_from_token(token, raise_exception=False)
|
35
|
+
return Usso(jwt_config=jwt_config).user_data_from_token(token, raise_exception=False)
|
36
36
|
|
37
37
|
|
38
|
-
def jwt_access_security(request: Request) -> UserData | None:
|
38
|
+
def jwt_access_security(request: Request, jwt_config=None) -> UserData | None:
|
39
39
|
"""Return the user associated with a token value."""
|
40
40
|
token = get_request_token(request)
|
41
41
|
if not token:
|
42
42
|
raise USSOException(
|
43
43
|
status_code=HTTP_401_UNAUTHORIZED,
|
44
44
|
error="unauthorized",
|
45
|
+
message="No token provided",
|
45
46
|
)
|
46
47
|
|
47
|
-
return Usso().user_data_from_token(token)
|
48
|
+
return Usso(jwt_config=jwt_config).user_data_from_token(token)
|
48
49
|
|
49
50
|
|
50
|
-
def jwt_access_security_ws(websocket: WebSocket) -> UserData | None:
|
51
|
+
def jwt_access_security_ws(websocket: WebSocket, jwt_config=None) -> UserData | None:
|
51
52
|
"""Return the user associated with a token value."""
|
52
53
|
token = get_request_token(websocket)
|
53
54
|
if not token:
|
54
55
|
raise USSOException(
|
55
56
|
status_code=HTTP_401_UNAUTHORIZED,
|
56
57
|
error="unauthorized",
|
58
|
+
message="No token provided",
|
57
59
|
)
|
58
60
|
|
59
|
-
return Usso().user_data_from_token(token)
|
61
|
+
return Usso(jwt_config=jwt_config).user_data_from_token(token)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: usso
|
3
|
-
Version: 0.25.
|
3
|
+
Version: 0.25.4
|
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>
|
@@ -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=
|
6
|
+
usso/core.py,sha256=tZzoh_t7HYr-HIual4hN7K1ZVk_nGZdKpaItq5VvkJQ,7087
|
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
|
13
|
-
usso-0.25.
|
14
|
-
usso-0.25.
|
15
|
-
usso-0.25.
|
16
|
-
usso-0.25.
|
17
|
-
usso-0.25.
|
18
|
-
usso-0.25.
|
12
|
+
usso/fastapi/integration.py,sha256=-8MTeqGokvmUO0lxZpEWXdTMYg6n065qtnaJHOwCrzQ,1890
|
13
|
+
usso-0.25.4.dist-info/LICENSE.txt,sha256=ceC9ZJOV9H6CtQDcYmHOS46NA3dHJ_WD4J9blH513pc,1081
|
14
|
+
usso-0.25.4.dist-info/METADATA,sha256=A_tGSXx1G-21gFFMscbvknkEdDumh0qZ3L4wlE7Nxxs,4194
|
15
|
+
usso-0.25.4.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
|
16
|
+
usso-0.25.4.dist-info/entry_points.txt,sha256=4Zgpm5ELaAWPf0jPGJFz1_X69H7un8ycT3WdGoJ0Vvk,35
|
17
|
+
usso-0.25.4.dist-info/top_level.txt,sha256=g9Jf6h1Oyidh0vPiFni7UHInTJjSvu6cUalpLTIvthg,5
|
18
|
+
usso-0.25.4.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|