architectonics 0.0.7__py3-none-any.whl → 0.0.9__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.
@@ -0,0 +1,52 @@
1
+ from uuid import UUID
2
+
3
+ from fastapi import Depends, Header, HTTPException
4
+ from starlette import status
5
+
6
+
7
+ def get_user_id(
8
+ x_user_id: str = Header(
9
+ alias="X-User-Id",
10
+ description="Идентификатор пользователя",
11
+ ),
12
+ ) -> str:
13
+ if not x_user_id:
14
+ raise HTTPException(
15
+ status_code=status.HTTP_400_BAD_REQUEST,
16
+ detail="X-User-Id header is required",
17
+ )
18
+
19
+ try:
20
+ _ = UUID(x_user_id, version=4) # version=4 для проверки UUID v4
21
+ except ValueError:
22
+ raise HTTPException(
23
+ status_code=status.HTTP_400_BAD_REQUEST,
24
+ detail="not_valid_uuid",
25
+ )
26
+
27
+ return x_user_id
28
+
29
+
30
+ def get_user_roles(
31
+ x_user_roles: str = Header(
32
+ alias="X-User-Roles",
33
+ description="Роли пользователя",
34
+ ),
35
+ ) -> str:
36
+ if not x_user_roles:
37
+ raise HTTPException(
38
+ status_code=status.HTTP_400_BAD_REQUEST,
39
+ detail="X-User-Roles header is required",
40
+ )
41
+
42
+ return x_user_roles.split(",")
43
+
44
+
45
+ class UserAuthService:
46
+ def __init__(
47
+ self,
48
+ user_id: str = Depends(get_user_id),
49
+ user_roles: list[str] = Depends(get_user_roles),
50
+ ):
51
+ self.user_id = user_id
52
+ self.user_roles = user_roles
File without changes
@@ -0,0 +1,11 @@
1
+ from fastapi import APIRouter
2
+
3
+ ping_router = APIRouter()
4
+
5
+
6
+ @ping_router.get(
7
+ "/ping/",
8
+ tags=["system"],
9
+ )
10
+ async def ping():
11
+ return {"ping": "pong"}
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: architectonics
3
- Version: 0.0.7
3
+ Version: 0.0.9
4
4
  Summary:
5
5
  Author: kirshuvl
6
6
  Author-email: kirshuvl@gmail.com
@@ -14,7 +14,10 @@ architectonics/services/exceptions.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJW
14
14
  architectonics/services/schemas.py,sha256=-UsD7L8_4tDGj3fW1QgOTJ2RFmkj1Osj-FvWfclM3AI,315
15
15
  architectonics/services/service.py,sha256=BRSks6i0oJyNdM-6tgpAGLOoBPBIesTNpqorcyX5dcs,4334
16
16
  architectonics/services/types.py,sha256=aKqbp5B-5Apt09jjz8wQH9GcA7Pe4qdwbRy7iFq2qTM,109
17
+ architectonics/services/user_auth_service.py,sha256=Cm5s8XWZcrDjH-yjhUZ4hC5mZQtrO0SjvR8qjnMzh6Q,1302
17
18
  architectonics/utils.py,sha256=a5dAvgfwYKQ5MwYaDxmy_YLHNHQxNgEH94YFuVrD4N0,84
18
- architectonics-0.0.7.dist-info/WHEEL,sha256=y3eDiaFVSNTPbgzfNn0nYn5tEn1cX6WrdetDlQM4xWw,83
19
- architectonics-0.0.7.dist-info/METADATA,sha256=-0Vhy2cdXNE6YONvM7wG25zvJUbYC7EpH9Z29bqV7SI,478
20
- architectonics-0.0.7.dist-info/RECORD,,
19
+ architectonics/views/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
+ architectonics/views/ping.py,sha256=ct2xO8Q1TKj-Z9eCN5beKkoR5S5vTYHYjlhpmh3k4tY,160
21
+ architectonics-0.0.9.dist-info/WHEEL,sha256=y3eDiaFVSNTPbgzfNn0nYn5tEn1cX6WrdetDlQM4xWw,83
22
+ architectonics-0.0.9.dist-info/METADATA,sha256=bRzt7sz-3LaV2axQs9cglG4BQjJ5Rfjc4JhQvtG9e7U,478
23
+ architectonics-0.0.9.dist-info/RECORD,,