trovesuite 1.0.13__py3-none-any.whl → 1.0.14__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.
@@ -234,7 +234,6 @@ class AuthService:
234
234
  FROM main.system_user_groups sug
235
235
  INNER JOIN main.system_assign_roles sar ON sug.group_id = sar.group_id
236
236
  WHERE sug.user_id = %s
237
- AND sug.delete_status = 'NOT_DELETED'
238
237
  AND sar.is_active = true
239
238
  AND sar.delete_status = 'NOT_DELETED'
240
239
  """,
@@ -347,18 +346,34 @@ class AuthService:
347
346
  def authorize_user_from_token(token: str) -> Respons[AuthServiceReadDto]:
348
347
  """
349
348
  Convenience method to authorize a user directly from a JWT token.
350
-
349
+
351
350
  Args:
352
351
  token: JWT token string
353
-
352
+
354
353
  Returns:
355
354
  Respons[AuthServiceReadDto]: Authorization result with user roles and permissions
356
-
355
+
357
356
  Raises:
358
357
  HTTPException: If token is invalid
359
358
  """
360
- user_info = AuthService.decode_token(token)
361
- return AuthService.authorize(user_info["user_id"], user_info["tenant_id"])
359
+ credentials_exception = HTTPException(
360
+ status_code=401,
361
+ detail="Could not validate credentials",
362
+ headers={"WWW-Authenticate": "Bearer"},
363
+ )
364
+ try:
365
+ payload = jwt.decode(token, db_settings.SECRET_KEY, algorithms=[db_settings.ALGORITHM])
366
+ user_id = payload.get("user_id")
367
+ tenant_id = payload.get("tenant_id")
368
+
369
+ if user_id is None or tenant_id is None:
370
+ raise credentials_exception
371
+
372
+ data = AuthServiceWriteDto(user_id=user_id, tenant_id=tenant_id)
373
+ return AuthService.authorize(data=data)
374
+
375
+ except jwt.InvalidTokenError as exc:
376
+ raise credentials_exception from exc
362
377
 
363
378
  @staticmethod
364
379
  def get_user_permissions(user_roles: list) -> list:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: trovesuite
3
- Version: 1.0.13
3
+ Version: 1.0.14
4
4
  Summary: TroveSuite services package providing authentication, authorization, notifications, Azure Storage, and other enterprise services for TroveSuite applications
5
5
  Home-page: https://dev.azure.com/brightgclt/trovesuite/_git/packages
6
6
  Author: Bright Debrah Owusu
@@ -3,7 +3,7 @@ trovesuite/auth/__init__.py,sha256=OjZllVvjul1glDazJ-d5TrNjgHFigFlQQi1G99DYshk,2
3
3
  trovesuite/auth/auth_base.py,sha256=rZHQVLeJRBQ8GClgF5UwG-er4_HXVX5-nt8o6_Z29uY,75
4
4
  trovesuite/auth/auth_controller.py,sha256=PAgaVlf5TYEfkSfK4vGGsvO84i8zEmeVVXyUF2YBppI,420
5
5
  trovesuite/auth/auth_read_dto.py,sha256=e27JqKVPVUM83A_mYF452QCflsvGNo7aKje7q_urwFc,571
6
- trovesuite/auth/auth_service.py,sha256=N5ax0rdGlHcu7cpJyAFrrwdkwKN8gsoh-t6ngIvXBAk,17548
6
+ trovesuite/auth/auth_service.py,sha256=_noR3A4Ss7ioP6j--MvlN0EWvcjs5Nljpa3u9zHDooY,18044
7
7
  trovesuite/auth/auth_write_dto.py,sha256=rdwI7w6-9QZGv1H0PAGrjkLBCzaMHjgPIXeLb9RmNec,234
8
8
  trovesuite/configs/__init__.py,sha256=h1mSZOaZ3kUy1ZMO_m9O9KklsxywM0RfMVZLh9h9WvQ,328
9
9
  trovesuite/configs/database.py,sha256=IPSu8fXjxyYeJ3bFknJG06Qm2L2ub6Ht19xhKv8g7nA,11731
@@ -26,8 +26,8 @@ trovesuite/storage/storage_service.py,sha256=V7LIePIV6b_iuhm-9x8r4zwpZHgeRPL1YIe
26
26
  trovesuite/storage/storage_write_dto.py,sha256=vl1iCZ93bpFmpvkCrn587QtMtOA_TPDseXSoTuj9RTQ,1355
27
27
  trovesuite/utils/__init__.py,sha256=3UPKTz9cluTgAM-ldNsJxsnoPTZiqacXlAmzUEHy6q8,143
28
28
  trovesuite/utils/helper.py,sha256=lvZ1mvaqY84dkIPB5Ov0uwYDOWBziAS8twobEJZh2Ik,1002
29
- trovesuite-1.0.13.dist-info/licenses/LICENSE,sha256=EJT35ct-Q794JYPdAQy3XNczQGKkU1HzToLeK1YVw2s,1070
30
- trovesuite-1.0.13.dist-info/METADATA,sha256=V0DYYd8qAzusR_UKkg--F4scCYY0PhONHhjoa6fZ91k,21737
31
- trovesuite-1.0.13.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
32
- trovesuite-1.0.13.dist-info/top_level.txt,sha256=GzKhG_-MTaxeHrIgkGkBH_nof2vroGFBrjeHKWUIwNc,11
33
- trovesuite-1.0.13.dist-info/RECORD,,
29
+ trovesuite-1.0.14.dist-info/licenses/LICENSE,sha256=EJT35ct-Q794JYPdAQy3XNczQGKkU1HzToLeK1YVw2s,1070
30
+ trovesuite-1.0.14.dist-info/METADATA,sha256=3A2HHGAEGEtZ1HTRflqCVmO6nhSewwiSrentaWVQSTQ,21737
31
+ trovesuite-1.0.14.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
32
+ trovesuite-1.0.14.dist-info/top_level.txt,sha256=GzKhG_-MTaxeHrIgkGkBH_nof2vroGFBrjeHKWUIwNc,11
33
+ trovesuite-1.0.14.dist-info/RECORD,,