usso 0.11.0__py3-none-any.whl → 0.12.0__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/fastapi/integration.py +23 -1
- {usso-0.11.0.dist-info → usso-0.12.0.dist-info}/METADATA +1 -1
- {usso-0.11.0.dist-info → usso-0.12.0.dist-info}/RECORD +7 -7
- {usso-0.11.0.dist-info → usso-0.12.0.dist-info}/LICENSE.txt +0 -0
- {usso-0.11.0.dist-info → usso-0.12.0.dist-info}/WHEEL +0 -0
- {usso-0.11.0.dist-info → usso-0.12.0.dist-info}/entry_points.txt +0 -0
- {usso-0.11.0.dist-info → usso-0.12.0.dist-info}/top_level.txt +0 -0
usso/fastapi/integration.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import logging
|
2
2
|
|
3
3
|
import jwt
|
4
|
-
from fastapi import Request
|
4
|
+
from fastapi import Request, WebSocket
|
5
5
|
from starlette.status import HTTP_401_UNAUTHORIZED
|
6
6
|
|
7
7
|
from usso.core import UserData, get_authorization_scheme_param, get_jwks_keys
|
@@ -77,3 +77,25 @@ async def jwt_access_security(request: Request) -> UserData | None:
|
|
77
77
|
error="unauthorized",
|
78
78
|
)
|
79
79
|
return None
|
80
|
+
|
81
|
+
|
82
|
+
async def jwt_access_security_ws(websocket: WebSocket) -> UserData | None:
|
83
|
+
"""Return the user associated with a token value."""
|
84
|
+
kwargs = {}
|
85
|
+
authorization = websocket.headers.get("Authorization")
|
86
|
+
if authorization:
|
87
|
+
scheme, _, credentials = get_authorization_scheme_param(authorization)
|
88
|
+
if scheme.lower() == "bearer":
|
89
|
+
token = credentials
|
90
|
+
return await user_data_from_token(token, **kwargs)
|
91
|
+
|
92
|
+
cookie_token = websocket.cookies.get("access_token")
|
93
|
+
if cookie_token:
|
94
|
+
return await user_data_from_token(cookie_token, **kwargs)
|
95
|
+
|
96
|
+
if kwargs.get("raise_exception", True):
|
97
|
+
raise USSOException(
|
98
|
+
status_code=HTTP_401_UNAUTHORIZED,
|
99
|
+
error="unauthorized",
|
100
|
+
)
|
101
|
+
return None
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: usso
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.12.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,10 +4,10 @@ usso/core.py,sha256=dYV6Oq7IFpSHKRIhKpCvvWF_a1r7cTHL_p35uxQi2ec,1114
|
|
4
4
|
usso/exceptions.py,sha256=hawOAuVbvQtjgRfwp1KFZ4SmV7fh720y5Gom9JVA8W8,504
|
5
5
|
usso/package_data.dat,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
6
6
|
usso/fastapi/__init__.py,sha256=lp2o47nCG-vIobgEOKdEnnPBGizv5om7oPXjqe0R9qU,67
|
7
|
-
usso/fastapi/integration.py,sha256=
|
8
|
-
usso-0.
|
9
|
-
usso-0.
|
10
|
-
usso-0.
|
11
|
-
usso-0.
|
12
|
-
usso-0.
|
13
|
-
usso-0.
|
7
|
+
usso/fastapi/integration.py,sha256=qJhJDprAxB0kEWqqIYZgNuNFZr9tFWTavhP0Mu39D5M,3364
|
8
|
+
usso-0.12.0.dist-info/LICENSE.txt,sha256=ceC9ZJOV9H6CtQDcYmHOS46NA3dHJ_WD4J9blH513pc,1081
|
9
|
+
usso-0.12.0.dist-info/METADATA,sha256=22uKL_AMKi9buPK83amShqq4oBrMsJ-Wakf_kcXP7m8,4306
|
10
|
+
usso-0.12.0.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
11
|
+
usso-0.12.0.dist-info/entry_points.txt,sha256=4Zgpm5ELaAWPf0jPGJFz1_X69H7un8ycT3WdGoJ0Vvk,35
|
12
|
+
usso-0.12.0.dist-info/top_level.txt,sha256=g9Jf6h1Oyidh0vPiFni7UHInTJjSvu6cUalpLTIvthg,5
|
13
|
+
usso-0.12.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|