spakky-fastapi 0.15.0__py3-none-any.whl → 0.17.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.
- spakky_fastapi/{aspects/jwt_auth.py → extensions/authenticate.py} +10 -10
- spakky_fastapi/plugins/authenticate.py +13 -0
- {spakky_fastapi-0.15.0.dist-info → spakky_fastapi-0.17.0.dist-info}/METADATA +1 -1
- {spakky_fastapi-0.15.0.dist-info → spakky_fastapi-0.17.0.dist-info}/RECORD +6 -6
- spakky_fastapi/plugins/jwt_auth.py +0 -10
- /spakky_fastapi/{aspects → extensions}/__init__.py +0 -0
- {spakky_fastapi-0.15.0.dist-info → spakky_fastapi-0.17.0.dist-info}/WHEEL +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 JWTAuth(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)]
|
@@ -52,7 +52,7 @@ class JWTAuth(FunctionAnnotation):
|
|
52
52
|
|
53
53
|
@Order(1)
|
54
54
|
@Aspect()
|
55
|
-
class
|
55
|
+
class AuthenticationAdvisor(IAdvisor):
|
56
56
|
__logger: Logger
|
57
57
|
__key: Key
|
58
58
|
|
@@ -61,9 +61,9 @@ class JWTAuthAdvisor(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:
|
@@ -81,7 +81,7 @@ class JWTAuthAdvisor(IAdvisor):
|
|
81
81
|
|
82
82
|
@Order(1)
|
83
83
|
@AsyncAspect()
|
84
|
-
class
|
84
|
+
class AsyncAuthenticationAdvisor(IAsyncAdvisor):
|
85
85
|
__logger: Logger
|
86
86
|
__key: Key
|
87
87
|
|
@@ -90,9 +90,9 @@ class AsyncJWTAuthAdvisor(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:
|
@@ -0,0 +1,13 @@
|
|
1
|
+
from spakky.application.interfaces.pluggable import IPluggable
|
2
|
+
from spakky.application.interfaces.registry import IRegistry
|
3
|
+
|
4
|
+
from spakky_fastapi.extensions.authenticate import (
|
5
|
+
AsyncAuthenticationAdvisor,
|
6
|
+
AuthenticationAdvisor,
|
7
|
+
)
|
8
|
+
|
9
|
+
|
10
|
+
class AuthenticatePlugin(IPluggable):
|
11
|
+
def register(self, registry: IRegistry) -> None:
|
12
|
+
registry.register_bean(AuthenticationAdvisor)
|
13
|
+
registry.register_bean(AsyncAuthenticationAdvisor)
|
@@ -1,16 +1,16 @@
|
|
1
1
|
spakky_fastapi/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
-
spakky_fastapi/aspects/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
3
|
-
spakky_fastapi/aspects/jwt_auth.py,sha256=1OSpCQDWiBzseH5IPfgutjQCNKabnNFMCRNQRBoENE8,4007
|
4
2
|
spakky_fastapi/error.py,sha256=SWyNZk1kxbTCiy-tLxB8saLpX5rBxwvy7q7JRCtNQV0,1124
|
3
|
+
spakky_fastapi/extensions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
4
|
+
spakky_fastapi/extensions/authenticate.py,sha256=HxLtejp3NaWaN9rRrTR42aTkd7chtglyt4GZjwpDYFE,4053
|
5
5
|
spakky_fastapi/middlewares/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
6
6
|
spakky_fastapi/middlewares/error_handling.py,sha256=SeqEZeGYdRvQTAcbVlcP6bGHXGi5RL9S6ZnsG6PDgTE,1712
|
7
7
|
spakky_fastapi/plugins/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
8
|
+
spakky_fastapi/plugins/authenticate.py,sha256=9enMrxzbX3XgnO44sl0DPzUhAv1aQpuZOJwnEOTt0Rw,445
|
8
9
|
spakky_fastapi/plugins/fast_api.py,sha256=lSXABplfyl3jASaT3NV4Z1hC-EtHqilXqyN98Y756v4,652
|
9
|
-
spakky_fastapi/plugins/jwt_auth.py,sha256=UN05gI9cYHrQERIYYigLqsFMxOdgvceusg6AZO1KN_Y,392
|
10
10
|
spakky_fastapi/post_processor.py,sha256=gTUubo-vOy_uB6rytT8vuNuRgQV2fOdsDqPx93cf8oI,2983
|
11
11
|
spakky_fastapi/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
12
12
|
spakky_fastapi/stereotypes/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
13
13
|
spakky_fastapi/stereotypes/api_controller.py,sha256=NM0gyTQfuHnENtvyfm5T9Y427gQdxdUcVYDzAXryF2M,19320
|
14
|
-
spakky_fastapi-0.
|
15
|
-
spakky_fastapi-0.
|
16
|
-
spakky_fastapi-0.
|
14
|
+
spakky_fastapi-0.17.0.dist-info/METADATA,sha256=8b4JoAKkJK5dWsTxaKFOfJuHGYkrAW53cU_jucvGb3I,1706
|
15
|
+
spakky_fastapi-0.17.0.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
|
16
|
+
spakky_fastapi-0.17.0.dist-info/RECORD,,
|
@@ -1,10 +0,0 @@
|
|
1
|
-
from spakky.application.interfaces.pluggable import IPluggable
|
2
|
-
from spakky.application.interfaces.registry import IRegistry
|
3
|
-
|
4
|
-
from spakky_fastapi.aspects.jwt_auth import AsyncJWTAuthAdvisor, JWTAuthAdvisor
|
5
|
-
|
6
|
-
|
7
|
-
class JWTAuthPlugin(IPluggable):
|
8
|
-
def register(self, registry: IRegistry) -> None:
|
9
|
-
registry.register_bean(JWTAuthAdvisor)
|
10
|
-
registry.register_bean(AsyncJWTAuthAdvisor)
|
File without changes
|
File without changes
|