aiteamutils 0.2.23__py3-none-any.whl → 0.2.25__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.
- aiteamutils/dependencies.py +16 -11
- aiteamutils/security.py +3 -4
- aiteamutils/version.py +1 -1
- {aiteamutils-0.2.23.dist-info → aiteamutils-0.2.25.dist-info}/METADATA +1 -1
- {aiteamutils-0.2.23.dist-info → aiteamutils-0.2.25.dist-info}/RECORD +6 -6
- {aiteamutils-0.2.23.dist-info → aiteamutils-0.2.25.dist-info}/WHEEL +0 -0
aiteamutils/dependencies.py
CHANGED
@@ -52,19 +52,24 @@ class ServiceRegistry:
|
|
52
52
|
service_registry = ServiceRegistry()
|
53
53
|
|
54
54
|
def get_service(name: str):
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
name (str): 서비스 이름
|
59
|
-
|
60
|
-
Returns:
|
61
|
-
Callable: 서비스 인스턴스를 반환하는 의존성 함수
|
62
|
-
"""
|
63
|
-
def _get_service(db: AsyncSession = Depends(get_db)):
|
64
|
-
db_service = DatabaseService(session=db)
|
55
|
+
def _get_service():
|
56
|
+
# 글로벌 DatabaseService 사용
|
57
|
+
db_service = get_database_service()
|
65
58
|
repository_class, service_class = service_registry.get(name)
|
59
|
+
|
60
|
+
# 이미 생성된 서비스가 있다면 재사용
|
61
|
+
if hasattr(service_registry, '_instances') and name in service_registry._instances:
|
62
|
+
return service_registry._instances[name]
|
63
|
+
|
66
64
|
repository = repository_class(db_service)
|
67
|
-
|
65
|
+
instance = service_class(repository, db_service)
|
66
|
+
|
67
|
+
# 생성된 인스턴스 캐싱
|
68
|
+
if not hasattr(service_registry, '_instances'):
|
69
|
+
service_registry._instances = {}
|
70
|
+
service_registry._instances[name] = instance
|
71
|
+
|
72
|
+
return instance
|
68
73
|
return _get_service
|
69
74
|
|
70
75
|
oauth2_scheme = OAuth2PasswordBearer(tokenUrl="/users/token")
|
aiteamutils/security.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
"""보안 관련 유틸리티."""
|
2
2
|
from datetime import datetime, timedelta, UTC
|
3
|
-
from typing import Dict, Any, Optional, Literal, Callable
|
3
|
+
from typing import Dict, Any, Optional, Literal, Callable, Type, Base
|
4
4
|
from fastapi import Request, HTTPException, status
|
5
5
|
from functools import wraps
|
6
6
|
from jose import jwt, JWTError
|
@@ -262,7 +262,7 @@ async def create_jwt_token(
|
|
262
262
|
user_data: Dict[str, Any],
|
263
263
|
token_type: Literal["access", "refresh"],
|
264
264
|
db_service: DatabaseService,
|
265
|
-
log_model:
|
265
|
+
log_model: Type[Base],
|
266
266
|
request: Optional[Request] = None
|
267
267
|
) -> str:
|
268
268
|
"""JWT 토큰을 생성하고 로그를 기록합니다.
|
@@ -271,7 +271,7 @@ async def create_jwt_token(
|
|
271
271
|
user_data: 사용자 데이터 딕셔너리 (username, ulid, name, role_ulid, status, organization 정보 등)
|
272
272
|
token_type: 토큰 타입 ("access" 또는 "refresh")
|
273
273
|
db_service: 데이터베이스 서비스
|
274
|
-
log_model: 로그 모델
|
274
|
+
log_model: 로그 모델 클래스
|
275
275
|
request: FastAPI 요청 객체
|
276
276
|
|
277
277
|
Returns:
|
@@ -293,7 +293,6 @@ async def create_jwt_token(
|
|
293
293
|
token_type=token_type
|
294
294
|
)
|
295
295
|
|
296
|
-
# 토큰 데이터 생성
|
297
296
|
if token_type == "access":
|
298
297
|
expires_at = datetime.now(UTC) + timedelta(minutes=settings.ACCESS_TOKEN_EXPIRE_MINUTES)
|
299
298
|
token_data = {
|
aiteamutils/version.py
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
"""버전 정보"""
|
2
|
-
__version__ = "0.2.
|
2
|
+
__version__ = "0.2.25"
|
@@ -5,12 +5,12 @@ aiteamutils/base_service.py,sha256=E4dHGE0DvhmRyFplh46SwKJOSF_nUL7OAsCkf_ZJF_8,2
|
|
5
5
|
aiteamutils/cache.py,sha256=tr0Yn8VPYA9QHiKCUzciVlQ2J1RAwNo2K9lGMH4rY3s,1334
|
6
6
|
aiteamutils/config.py,sha256=7pJHBml8RRXC9FpoRBx0emofFkvtxsyk9_Rcur2F9hI,2724
|
7
7
|
aiteamutils/database.py,sha256=raYKRZjEfefM3SnoPYozPu7OUGm62XWOUqZzN4_cayw,33479
|
8
|
-
aiteamutils/dependencies.py,sha256=
|
8
|
+
aiteamutils/dependencies.py,sha256=VIpy8InbmSd0yOtQYMnn-0rz8yVQwHHbB1xK9Gc7WOw,4275
|
9
9
|
aiteamutils/enums.py,sha256=ipZi6k_QD5-3QV7Yzv7bnL0MjDz-vqfO9I5L77biMKs,632
|
10
10
|
aiteamutils/exceptions.py,sha256=YV-ISya4wQlHk4twvGo16I5r8h22-tXpn9wa-b3WwDM,15231
|
11
|
-
aiteamutils/security.py,sha256=
|
11
|
+
aiteamutils/security.py,sha256=t1xdvfy2qpggiQGr89AMuRKvWK1UFMxJiJYAE5Lek7o,13453
|
12
12
|
aiteamutils/validators.py,sha256=3N245cZFjgwtW_KzjESkizx5BBUDaJLbbxfNO4WOFZ0,7764
|
13
|
-
aiteamutils/version.py,sha256=
|
14
|
-
aiteamutils-0.2.
|
15
|
-
aiteamutils-0.2.
|
16
|
-
aiteamutils-0.2.
|
13
|
+
aiteamutils/version.py,sha256=twTFpzolvc7RqGZVG8NMtyztFRFxTGhSsOxiknGfolo,44
|
14
|
+
aiteamutils-0.2.25.dist-info/METADATA,sha256=1adRJ-4J_keHTi-Oga8lzoqbUAsqG-pymSUuhQmxmlc,1718
|
15
|
+
aiteamutils-0.2.25.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
16
|
+
aiteamutils-0.2.25.dist-info/RECORD,,
|
File without changes
|