spakky-fastapi 0.16.0__tar.gz → 0.17.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.
- {spakky_fastapi-0.16.0 → spakky_fastapi-0.17.0}/PKG-INFO +1 -1
- {spakky_fastapi-0.16.0 → spakky_fastapi-0.17.0}/pyproject.toml +1 -1
- spakky_fastapi-0.16.0/spakky_fastapi/extensions/auth.py → spakky_fastapi-0.17.0/spakky_fastapi/extensions/authenticate.py +8 -8
- spakky_fastapi-0.16.0/spakky_fastapi/plugins/jwt_auth.py → spakky_fastapi-0.17.0/spakky_fastapi/plugins/authenticate.py +2 -2
- {spakky_fastapi-0.16.0 → spakky_fastapi-0.17.0}/README.md +0 -0
- {spakky_fastapi-0.16.0 → spakky_fastapi-0.17.0}/spakky_fastapi/__init__.py +0 -0
- {spakky_fastapi-0.16.0 → spakky_fastapi-0.17.0}/spakky_fastapi/error.py +0 -0
- {spakky_fastapi-0.16.0 → spakky_fastapi-0.17.0}/spakky_fastapi/extensions/__init__.py +0 -0
- {spakky_fastapi-0.16.0 → spakky_fastapi-0.17.0}/spakky_fastapi/middlewares/__init__.py +0 -0
- {spakky_fastapi-0.16.0 → spakky_fastapi-0.17.0}/spakky_fastapi/middlewares/error_handling.py +0 -0
- {spakky_fastapi-0.16.0 → spakky_fastapi-0.17.0}/spakky_fastapi/plugins/__init__.py +0 -0
- {spakky_fastapi-0.16.0 → spakky_fastapi-0.17.0}/spakky_fastapi/plugins/fast_api.py +0 -0
- {spakky_fastapi-0.16.0 → spakky_fastapi-0.17.0}/spakky_fastapi/post_processor.py +0 -0
- {spakky_fastapi-0.16.0 → spakky_fastapi-0.17.0}/spakky_fastapi/py.typed +0 -0
- {spakky_fastapi-0.16.0 → spakky_fastapi-0.17.0}/spakky_fastapi/stereotypes/__init__.py +0 -0
- {spakky_fastapi-0.16.0 → spakky_fastapi-0.17.0}/spakky_fastapi/stereotypes/api_controller.py +0 -0
@@ -25,14 +25,14 @@ class AuthenticationFailedError(SpakkyAOPError):
|
|
25
25
|
message = "사용자 인증에 실패했습니다."
|
26
26
|
|
27
27
|
|
28
|
-
|
28
|
+
IAuthenticateFunction: TypeAlias = (
|
29
29
|
Callable[Concatenate[Any, JWT, P], R_co]
|
30
30
|
| Callable[Concatenate[Any, JWT, P], Awaitable[R_co]]
|
31
31
|
)
|
32
32
|
|
33
33
|
|
34
34
|
@dataclass
|
35
|
-
class
|
35
|
+
class Authenticate(FunctionAnnotation):
|
36
36
|
token_url: InitVar[str]
|
37
37
|
authenticator: OAuth2PasswordBearer = field(init=False)
|
38
38
|
token_keywords: list[str] = field(init=False, default_factory=list)
|
@@ -41,8 +41,8 @@ class Auth(FunctionAnnotation):
|
|
41
41
|
self.authenticator = OAuth2PasswordBearer(tokenUrl=token_url)
|
42
42
|
|
43
43
|
def __call__(
|
44
|
-
self, obj:
|
45
|
-
) ->
|
44
|
+
self, obj: IAuthenticateFunction[P, R_co]
|
45
|
+
) -> IAuthenticateFunction[P, R_co]:
|
46
46
|
for key, value in obj.__annotations__.items():
|
47
47
|
if value == JWT:
|
48
48
|
obj.__annotations__[key] = Annotated[JWT, Depends(self.authenticator)]
|
@@ -61,9 +61,9 @@ class AuthenticationAdvisor(IAdvisor):
|
|
61
61
|
self.__logger = logger
|
62
62
|
self.__key = key
|
63
63
|
|
64
|
-
@Around(lambda x:
|
64
|
+
@Around(lambda x: Authenticate.contains(x) and not iscoroutinefunction(x))
|
65
65
|
def around(self, joinpoint: Func, *args: Any, **kwargs: Any) -> Any:
|
66
|
-
annotation:
|
66
|
+
annotation: Authenticate = Authenticate.single(joinpoint)
|
67
67
|
for keyword in annotation.token_keywords:
|
68
68
|
token: str = kwargs[keyword]
|
69
69
|
try:
|
@@ -90,9 +90,9 @@ class AsyncAuthenticationAdvisor(IAsyncAdvisor):
|
|
90
90
|
self.__logger = logger
|
91
91
|
self.__key = key
|
92
92
|
|
93
|
-
@Around(lambda x:
|
93
|
+
@Around(lambda x: Authenticate.contains(x) and iscoroutinefunction(x))
|
94
94
|
async def around_async(self, joinpoint: AsyncFunc, *args: Any, **kwargs: Any) -> Any:
|
95
|
-
annotation:
|
95
|
+
annotation: Authenticate = Authenticate.single(joinpoint)
|
96
96
|
for keyword in annotation.token_keywords:
|
97
97
|
token: str = kwargs[keyword]
|
98
98
|
try:
|
@@ -1,13 +1,13 @@
|
|
1
1
|
from spakky.application.interfaces.pluggable import IPluggable
|
2
2
|
from spakky.application.interfaces.registry import IRegistry
|
3
3
|
|
4
|
-
from spakky_fastapi.extensions.
|
4
|
+
from spakky_fastapi.extensions.authenticate import (
|
5
5
|
AsyncAuthenticationAdvisor,
|
6
6
|
AuthenticationAdvisor,
|
7
7
|
)
|
8
8
|
|
9
9
|
|
10
|
-
class
|
10
|
+
class AuthenticatePlugin(IPluggable):
|
11
11
|
def register(self, registry: IRegistry) -> None:
|
12
12
|
registry.register_bean(AuthenticationAdvisor)
|
13
13
|
registry.register_bean(AsyncAuthenticationAdvisor)
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{spakky_fastapi-0.16.0 → spakky_fastapi-0.17.0}/spakky_fastapi/middlewares/error_handling.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{spakky_fastapi-0.16.0 → spakky_fastapi-0.17.0}/spakky_fastapi/stereotypes/api_controller.py
RENAMED
File without changes
|