aiteamutils 0.2.45__py3-none-any.whl → 0.2.47__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
aiteamutils/database.py CHANGED
@@ -1020,6 +1020,7 @@ async def get_db() -> AsyncGenerator[AsyncSession, None]:
1020
1020
  source_function="get_db"
1021
1021
  )
1022
1022
 
1023
+ session = None
1023
1024
  try:
1024
1025
  async with db_service.get_session() as session:
1025
1026
  if session is None:
@@ -1042,6 +1043,8 @@ async def get_db() -> AsyncGenerator[AsyncSession, None]:
1042
1043
 
1043
1044
  yield session
1044
1045
  except Exception as e:
1046
+ if isinstance(e, CustomException):
1047
+ raise e
1045
1048
  raise CustomException(
1046
1049
  ErrorCode.DB_CONNECTION_ERROR,
1047
1050
  detail=f"Failed to get database session: {str(e)}",
@@ -1049,7 +1052,7 @@ async def get_db() -> AsyncGenerator[AsyncSession, None]:
1049
1052
  original_error=e
1050
1053
  )
1051
1054
  finally:
1052
- if 'session' in locals() and session is not None:
1055
+ if session:
1053
1056
  await session.close()
1054
1057
 
1055
1058
  async def get_database_service() -> DatabaseService:
@@ -60,7 +60,19 @@ def get_service(name: str):
60
60
  try:
61
61
  repository_class, service_class = service_registry.get(name)
62
62
  repository = repository_class(db_service)
63
- return service_class(repository, db_service)
63
+ service = service_class(repository, db_service)
64
+
65
+ # 세션 생성 및 설정
66
+ async with db_service.get_session() as session:
67
+ if session is None:
68
+ raise CustomException(
69
+ ErrorCode.DB_CONNECTION_ERROR,
70
+ detail="Failed to create database session",
71
+ source_function="dependencies.get_service"
72
+ )
73
+ service.session = session
74
+ return service
75
+
64
76
  except CustomException as e:
65
77
  raise e
66
78
  except Exception as e:
@@ -95,7 +107,7 @@ async def get_current_user(
95
107
  token,
96
108
  settings.JWT_SECRET,
97
109
  algorithms=[settings.JWT_ALGORITHM],
98
- audience="ai-team"
110
+ audience=settings.TOKEN_AUDIENCE
99
111
  )
100
112
  user_ulid = payload.get("sub")
101
113
  if not user_ulid:
aiteamutils/security.py CHANGED
@@ -351,7 +351,7 @@ async def create_jwt_token(
351
351
  token_data = {
352
352
  # 등록 클레임
353
353
  "iss": settings.TOKEN_ISSUER,
354
- "sub": user_data["username"],
354
+ "sub": user_data["ulid"],
355
355
  "aud": settings.TOKEN_AUDIENCE,
356
356
  "exp": expires_at,
357
357
 
@@ -376,7 +376,7 @@ async def create_jwt_token(
376
376
  expires_at = datetime.now(UTC) + timedelta(days=14)
377
377
  token_data = {
378
378
  "iss": settings.TOKEN_ISSUER,
379
- "sub": user_data["username"],
379
+ "sub": user_data["ulid"],
380
380
  "exp": expires_at,
381
381
  "token_type": token_type,
382
382
  "user_ulid": user_data["ulid"]
aiteamutils/version.py CHANGED
@@ -1,2 +1,2 @@
1
1
  """버전 정보"""
2
- __version__ = "0.2.45"
2
+ __version__ = "0.2.47"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aiteamutils
3
- Version: 0.2.45
3
+ Version: 0.2.47
4
4
  Summary: AI Team Utilities
5
5
  Project-URL: Homepage, https://github.com/yourusername/aiteamutils
6
6
  Project-URL: Issues, https://github.com/yourusername/aiteamutils/issues
@@ -4,13 +4,13 @@ aiteamutils/base_repository.py,sha256=qdwQ7Sj2fUqxpDg6cWM48n_QbwPK_VUlG9zTSem8iC
4
4
  aiteamutils/base_service.py,sha256=E4dHGE0DvhmRyFplh46SwKJOSF_nUL7OAsCkf_ZJF_8,24733
5
5
  aiteamutils/cache.py,sha256=07xBGlgAwOTAdY5mnMOQJ5EBxVwe8glVD7DkGEkxCtw,1373
6
6
  aiteamutils/config.py,sha256=OM_b7g8sqZ3zY_DSF9ry-zn5wn4dlXdx5OhjfTGr0TE,2876
7
- aiteamutils/database.py,sha256=PZOggFB8KfkoCxzHhP5GGeBjee-FM6Hr_no8c7uhAMU,40129
8
- aiteamutils/dependencies.py,sha256=cNV1ym6PIUQqwsQVtpgw92MKWefB3Bz781QSuC3XswQ,4317
7
+ aiteamutils/database.py,sha256=xUvxSRG49AY5DIWkucKMsaMMtfg5GumgJRwwwiUXm5w,40173
8
+ aiteamutils/dependencies.py,sha256=UC19hLf5LHM4fdqVQHo7fHxytD47lkXuiSQvU2Vd4s0,4827
9
9
  aiteamutils/enums.py,sha256=ipZi6k_QD5-3QV7Yzv7bnL0MjDz-vqfO9I5L77biMKs,632
10
10
  aiteamutils/exceptions.py,sha256=_lKWXq_ujNj41xN6LDE149PwsecAP7lgYWbOBbLOntg,15368
11
- aiteamutils/security.py,sha256=9gvEqDtE3RJaoCWqELPCjkg-IsSqZVrpMP6XPZaodWU,16024
11
+ aiteamutils/security.py,sha256=KSZf3WJAlW0UXVM1GEHwuGy2x27UHwtMr8aq-GuIXZk,16016
12
12
  aiteamutils/validators.py,sha256=3N245cZFjgwtW_KzjESkizx5BBUDaJLbbxfNO4WOFZ0,7764
13
- aiteamutils/version.py,sha256=3bhfB0cuuuM8bgbYGCGGzo-Hv2L0C7qDN7ifS_5ye8w,42
14
- aiteamutils-0.2.45.dist-info/METADATA,sha256=8QyZGVPAX3i8lglFHb8fi3xSH7qRM9ZXG7tzhpy3_5E,1718
15
- aiteamutils-0.2.45.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
16
- aiteamutils-0.2.45.dist-info/RECORD,,
13
+ aiteamutils/version.py,sha256=o2IXukuF7KexqFBwlqOtUGuZABgd7WMZRzbAfk0_sdU,42
14
+ aiteamutils-0.2.47.dist-info/METADATA,sha256=BqLPd9L224PbbrWL3Z4zcblCVV3oRcarMpS3o2Iipb8,1718
15
+ aiteamutils-0.2.47.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
16
+ aiteamutils-0.2.47.dist-info/RECORD,,