spakky-fastapi 0.7.17__tar.gz → 0.7.19__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.
- {spakky_fastapi-0.7.17 → spakky_fastapi-0.7.19}/PKG-INFO +2 -2
- {spakky_fastapi-0.7.17 → spakky_fastapi-0.7.19}/pyproject.toml +2 -2
- {spakky_fastapi-0.7.17 → spakky_fastapi-0.7.19}/spakky_fastapi/jwt_auth.py +18 -15
- {spakky_fastapi-0.7.17 → spakky_fastapi-0.7.19}/README.md +0 -0
- {spakky_fastapi-0.7.17 → spakky_fastapi-0.7.19}/spakky_fastapi/__init__.py +0 -0
- {spakky_fastapi-0.7.17 → spakky_fastapi-0.7.19}/spakky_fastapi/error.py +0 -0
- {spakky_fastapi-0.7.17 → spakky_fastapi-0.7.19}/spakky_fastapi/middlewares/__init__.py +0 -0
- {spakky_fastapi-0.7.17 → spakky_fastapi-0.7.19}/spakky_fastapi/middlewares/error_handling.py +0 -0
- {spakky_fastapi-0.7.17 → spakky_fastapi-0.7.19}/spakky_fastapi/post_processor.py +0 -0
- {spakky_fastapi-0.7.17 → spakky_fastapi-0.7.19}/spakky_fastapi/py.typed +0 -0
- {spakky_fastapi-0.7.17 → spakky_fastapi-0.7.19}/spakky_fastapi/routing.py +0 -0
- {spakky_fastapi-0.7.17 → spakky_fastapi-0.7.19}/spakky_fastapi/stereotypes/__init__.py +0 -0
- {spakky_fastapi-0.7.17 → spakky_fastapi-0.7.19}/spakky_fastapi/stereotypes/api_controller.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: spakky-fastapi
|
3
|
-
Version: 0.7.
|
3
|
+
Version: 0.7.19
|
4
4
|
Summary: Highly abstracted Framework core to use DDD & DI/IoC & AOP & Etc...
|
5
5
|
Author: Spakky
|
6
6
|
Author-email: sejong418@icloud.com
|
@@ -11,7 +11,7 @@ Classifier: Programming Language :: Python :: 3.11
|
|
11
11
|
Classifier: Programming Language :: Python :: 3.12
|
12
12
|
Requires-Dist: fastapi (>=0.109.2,<0.110.0)
|
13
13
|
Requires-Dist: orjson (>=3.9.15,<4.0.0)
|
14
|
-
Requires-Dist: spakky-core (>=0.7.
|
14
|
+
Requires-Dist: spakky-core (>=0.7.14)
|
15
15
|
Requires-Dist: websockets (>=12.0,<13.0)
|
16
16
|
Description-Content-Type: text/markdown
|
17
17
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
[tool.poetry]
|
2
2
|
name = "spakky-fastapi"
|
3
|
-
version = "0.7.
|
3
|
+
version = "0.7.19"
|
4
4
|
description = "Highly abstracted Framework core to use DDD & DI/IoC & AOP & Etc..."
|
5
5
|
authors = ["Spakky <sejong418@icloud.com>"]
|
6
6
|
readme = "README.md"
|
@@ -12,7 +12,7 @@ build-backend = "poetry.core.masonry.api"
|
|
12
12
|
[tool.poetry.dependencies]
|
13
13
|
python = ">=3.10"
|
14
14
|
fastapi = "^0.109.2"
|
15
|
-
spakky-core = ">=0.7.
|
15
|
+
spakky-core = ">=0.7.14"
|
16
16
|
websockets = "^12.0"
|
17
17
|
orjson = "^3.9.15"
|
18
18
|
|
@@ -31,6 +31,7 @@ IAuthenticatedFunction: TypeAlias = Callable[Concatenate[Any, JWT, P], Awaitable
|
|
31
31
|
class JWTAuth(FunctionAnnotation):
|
32
32
|
token_url: InitVar[str]
|
33
33
|
authenticator: OAuth2PasswordBearer = field(init=False)
|
34
|
+
token_keywords: list[str] = field(init=False, default_factory=list)
|
34
35
|
|
35
36
|
def __post_init__(self, token_url: str) -> None:
|
36
37
|
self.authenticator = OAuth2PasswordBearer(tokenUrl=token_url)
|
@@ -38,10 +39,10 @@ class JWTAuth(FunctionAnnotation):
|
|
38
39
|
def __call__(
|
39
40
|
self, obj: IAuthenticatedFunction[P, R_co]
|
40
41
|
) -> IAuthenticatedFunction[P, R_co]:
|
41
|
-
obj.__annotations__
|
42
|
-
|
43
|
-
|
44
|
-
|
42
|
+
for key, value in obj.__annotations__.items():
|
43
|
+
if value == JWT:
|
44
|
+
obj.__annotations__[key] = Annotated[JWT, Depends(self.authenticator)]
|
45
|
+
self.token_keywords.append(key)
|
45
46
|
return super().__call__(obj)
|
46
47
|
|
47
48
|
|
@@ -59,15 +60,17 @@ class AsyncJWTAuthAdvisor(IAsyncAdvisor):
|
|
59
60
|
|
60
61
|
@Around(JWTAuth.contains)
|
61
62
|
async def around_async(self, joinpoint: AsyncFunc, *args: Any, **kwargs: Any) -> Any:
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
63
|
+
annotation: JWTAuth = JWTAuth.single(joinpoint)
|
64
|
+
for keyword in annotation.token_keywords:
|
65
|
+
token: str = kwargs[keyword]
|
66
|
+
try:
|
67
|
+
jwt: JWT = JWT(token=token)
|
68
|
+
except (InvalidJWTFormatError, JWTDecodingError) as e:
|
69
|
+
raise Unauthorized(AuthenticationFailedError()) from e
|
70
|
+
if jwt.is_expired:
|
71
|
+
raise Unauthorized(AuthenticationFailedError())
|
72
|
+
if jwt.verify(self.__key) is False:
|
73
|
+
raise Unauthorized(AuthenticationFailedError())
|
74
|
+
self.__logger.info(f"[{type(self).__name__}] {jwt.payload!r}")
|
75
|
+
kwargs[keyword] = jwt
|
73
76
|
return await joinpoint(*args, **kwargs)
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{spakky_fastapi-0.7.17 → spakky_fastapi-0.7.19}/spakky_fastapi/middlewares/error_handling.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{spakky_fastapi-0.7.17 → spakky_fastapi-0.7.19}/spakky_fastapi/stereotypes/api_controller.py
RENAMED
File without changes
|