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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: spakky-fastapi
3
- Version: 0.16.0
3
+ Version: 0.17.0
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
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "spakky-fastapi"
3
- version = "0.16.0"
3
+ version = "0.17.0"
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"
@@ -25,14 +25,14 @@ class AuthenticationFailedError(SpakkyAOPError):
25
25
  message = "사용자 인증에 실패했습니다."
26
26
 
27
27
 
28
- IAuthenticatedFunction: TypeAlias = (
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 Auth(FunctionAnnotation):
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: IAuthenticatedFunction[P, R_co]
45
- ) -> IAuthenticatedFunction[P, R_co]:
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: Auth.contains(x) and not iscoroutinefunction(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: Auth = Auth.single(joinpoint)
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: Auth.contains(x) and iscoroutinefunction(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: Auth = Auth.single(joinpoint)
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.auth import (
4
+ from spakky_fastapi.extensions.authenticate import (
5
5
  AsyncAuthenticationAdvisor,
6
6
  AuthenticationAdvisor,
7
7
  )
8
8
 
9
9
 
10
- class JWTAuthPlugin(IPluggable):
10
+ class AuthenticatePlugin(IPluggable):
11
11
  def register(self, registry: IRegistry) -> None:
12
12
  registry.register_bean(AuthenticationAdvisor)
13
13
  registry.register_bean(AsyncAuthenticationAdvisor)