zrb 0.9.2__py3-none-any.whl → 0.10.0__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.
- zrb/__init__.py +2 -0
- zrb/builtin/generator/docker_compose_task/template/src/kebab-zrb-task-name/image/Dockerfile +1 -0
- zrb/builtin/generator/docker_compose_task/template/src/kebab-zrb-task-name/image/pyproject.toml +1 -1
- zrb/builtin/generator/fastapp/add.py +17 -5
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/loadtest/pyproject.toml +1 -1
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/Dockerfile +1 -0
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/config.py +3 -1
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/entity/group/api.py +67 -52
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/entity/permission/api.py +67 -54
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/entity/user/api.py +85 -67
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/log/entity/activity/api.py +30 -23
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/log/entity/activity/event.py +1 -3
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/pyproject.toml +1 -1
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/start.sh +20 -15
- zrb/builtin/generator/fastapp_crud/template/src/kebab-zrb-app-name/src/module/snake_zrb_module_name/entity/snake_zrb_entity_name/api.py +82 -58
- zrb/builtin/generator/fastapp_crud/template/src/kebab-zrb-app-name/src/module/snake_zrb_module_name/schema/snake_zrb_entity_name.py +1 -1
- zrb/builtin/generator/fastapp_field/helper.py +1 -1
- zrb/builtin/generator/pip_package/template/_automate/snake_zrb_package_name/cmd/publish.sh +1 -1
- zrb/builtin/generator/pip_package/template/_automate/snake_zrb_package_name/local.py +1 -9
- zrb/builtin/generator/pip_package/template/src/kebab-zrb-package-name/pyproject.toml +1 -1
- zrb/builtin/generator/plugin/template/_cmd/publish.sh +1 -1
- zrb/builtin/generator/plugin/template/pyproject.toml +1 -1
- zrb/builtin/generator/plugin/template/zrb_init.py +1 -9
- zrb/builtin/generator/project/template/pyproject.toml +1 -1
- zrb/builtin/generator/simple_python_app/template/src/kebab-zrb-app-name/src/Dockerfile +1 -0
- zrb/builtin/generator/simple_python_app/template/src/kebab-zrb-app-name/src/pyproject.toml +1 -1
- zrb/config/config.py +10 -7
- zrb/helper/accessories/name.py +60 -116
- zrb/helper/codemod/add_property_to_class.py +18 -1
- zrb/shell-scripts/ensure-podman-is-installed.sh +55 -0
- zrb/task/any_task.py +83 -0
- zrb/task/base_remote_cmd_task.py +2 -0
- zrb/task/base_task/base_task.py +53 -15
- zrb/task/base_task/component/base_task_model.py +2 -0
- zrb/task/base_task/component/common_task_model.py +26 -0
- zrb/task/checker.py +2 -0
- zrb/task/cmd_task.py +2 -0
- zrb/task/docker_compose_task.py +27 -21
- zrb/task/flow_task.py +2 -0
- zrb/task/http_checker.py +2 -0
- zrb/task/notifier.py +2 -0
- zrb/task/path_checker.py +2 -0
- zrb/task/path_watcher.py +2 -0
- zrb/task/port_checker.py +2 -0
- zrb/task/recurring_task.py +2 -0
- zrb/task/remote_cmd_task.py +2 -0
- zrb/task/resource_maker.py +2 -0
- zrb/task/rsync_task.py +2 -0
- zrb/task/time_watcher.py +2 -0
- zrb/task/wiki_task.py +119 -0
- {zrb-0.9.2.dist-info → zrb-0.10.0.dist-info}/METADATA +1 -1
- {zrb-0.9.2.dist-info → zrb-0.10.0.dist-info}/RECORD +55 -53
- {zrb-0.9.2.dist-info → zrb-0.10.0.dist-info}/LICENSE +0 -0
- {zrb-0.9.2.dist-info → zrb-0.10.0.dist-info}/WHEEL +0 -0
- {zrb-0.9.2.dist-info → zrb-0.10.0.dist-info}/entry_points.txt +0 -0
zrb/__init__.py
CHANGED
@@ -28,6 +28,7 @@ from zrb.task.resource_maker import Replacement, ReplacementMutator, ResourceMak
|
|
28
28
|
from zrb.task.rsync_task import RsyncTask
|
29
29
|
from zrb.task.task import Task
|
30
30
|
from zrb.task.time_watcher import TimeWatcher
|
31
|
+
from zrb.task.wiki_task import create_wiki_tasks
|
31
32
|
from zrb.task_env.env import Env
|
32
33
|
from zrb.task_env.env_file import EnvFile
|
33
34
|
from zrb.task_group.group import Group
|
@@ -40,6 +41,7 @@ from zrb.task_input.password_input import PasswordInput
|
|
40
41
|
from zrb.task_input.str_input import StrInput
|
41
42
|
from zrb.task_input.task_input import Input
|
42
43
|
|
44
|
+
assert create_wiki_tasks
|
43
45
|
assert runner
|
44
46
|
assert AnyTask
|
45
47
|
assert OnTriggered
|
@@ -85,11 +85,23 @@ copy_resource = ResourceMaker(
|
|
85
85
|
excludes=[
|
86
86
|
"*/__pycache__",
|
87
87
|
"*/deployment/venv",
|
88
|
-
"*/src/kebab-app-name/.venv",
|
89
|
-
"*/src/kebab-app-name/src/frontend/node_modules",
|
90
|
-
"*/src/kebab-app-name/src/frontend/build",
|
91
|
-
"*/src/kebab-app-name/src/frontend/.svelte-kit",
|
92
|
-
|
88
|
+
"*/src/kebab-zrb-app-name/.venv",
|
89
|
+
"*/src/kebab-zrb-app-name/src/frontend/node_modules",
|
90
|
+
"*/src/kebab-zrb-app-name/src/frontend/build",
|
91
|
+
"*/src/kebab-zrb-app-name/src/frontend/.svelte-kit",
|
92
|
+
],
|
93
|
+
skip_parsing=[
|
94
|
+
"*.mp3",
|
95
|
+
"*.pdf",
|
96
|
+
"*.exe",
|
97
|
+
"*.dll",
|
98
|
+
"*.bin",
|
99
|
+
"*.iso",
|
100
|
+
"*.png",
|
101
|
+
"*.jpg",
|
102
|
+
"*.gif",
|
103
|
+
"*.ico",
|
104
|
+
"*/monitoring/clickhouse/user_scripts/histogramQuantile",
|
93
105
|
],
|
94
106
|
)
|
95
107
|
|
@@ -14,7 +14,9 @@ app_reload = str_to_boolean(os.getenv("APP_RELOAD", "true"))
|
|
14
14
|
app_max_not_ready = int(os.getenv("APP_MAX_NOT_READY", "10"))
|
15
15
|
|
16
16
|
app_enable_otel = str_to_boolean(os.getenv("APP_ENABLE_OTEL", "false"))
|
17
|
-
app_otel_exporter_otlp_endpoint = os.getenv(
|
17
|
+
app_otel_exporter_otlp_endpoint = os.getenv(
|
18
|
+
"APP_OTEL_EXPORTER_OTLP_ENDPOINT", "http://localhost:4317"
|
19
|
+
)
|
18
20
|
|
19
21
|
app_auth_access_token_cookie_key = os.getenv(
|
20
22
|
"PUBLIC_AUTH_ACCESS_TOKEN_COOKIE_KEY", "access_token"
|
zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/entity/group/api.py
CHANGED
@@ -8,6 +8,9 @@ from module.auth.component import Authorizer
|
|
8
8
|
from module.auth.integration import access_token_scheme
|
9
9
|
from module.auth.schema.group import Group, GroupData, GroupResult
|
10
10
|
from module.auth.schema.token import AccessTokenData
|
11
|
+
from opentelemetry import trace
|
12
|
+
|
13
|
+
tracer = trace.get_tracer(__name__)
|
11
14
|
|
12
15
|
|
13
16
|
def register_api(
|
@@ -26,20 +29,22 @@ def register_api(
|
|
26
29
|
offset: int = 0,
|
27
30
|
user_token_data: AccessTokenData = Depends(access_token_scheme),
|
28
31
|
):
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
32
|
+
with tracer.start_as_current_span("authorizer.is_having_permission"):
|
33
|
+
if not await authorizer.is_having_permission(
|
34
|
+
user_token_data.user_id, "auth:permission:get"
|
35
|
+
):
|
36
|
+
raise HTTPAPIException(403, "Unauthorized")
|
33
37
|
try:
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
38
|
+
with tracer.start_as_current_span("auth.rpc.auth_get_group"):
|
39
|
+
result_dict = await rpc_caller.call(
|
40
|
+
"auth_get_group",
|
41
|
+
keyword=keyword,
|
42
|
+
criterion={},
|
43
|
+
limit=limit,
|
44
|
+
offset=offset,
|
45
|
+
user_token_data=user_token_data.model_dump(),
|
46
|
+
)
|
47
|
+
return GroupResult(**result_dict)
|
43
48
|
except Exception as e:
|
44
49
|
raise HTTPAPIException(error=e)
|
45
50
|
|
@@ -47,17 +52,19 @@ def register_api(
|
|
47
52
|
async def get_group_by_id(
|
48
53
|
id: str, user_token_data: AccessTokenData = Depends(access_token_scheme)
|
49
54
|
):
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
55
|
+
with tracer.start_as_current_span("authorizer.is_having_permission"):
|
56
|
+
if not await authorizer.is_having_permission(
|
57
|
+
user_token_data.user_id, "auth:group:get_by_id"
|
58
|
+
):
|
59
|
+
raise HTTPAPIException(403, "Unauthorized")
|
54
60
|
try:
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
+
with tracer.start_as_current_span("auth.rpc.auth_get_group_by_id"):
|
62
|
+
result_dict = await rpc_caller.call(
|
63
|
+
"auth_get_group_by_id",
|
64
|
+
id=id,
|
65
|
+
user_token_data=user_token_data.model_dump(),
|
66
|
+
)
|
67
|
+
return Group(**result_dict)
|
61
68
|
except Exception as e:
|
62
69
|
raise HTTPAPIException(error=e)
|
63
70
|
|
@@ -65,17 +72,19 @@ def register_api(
|
|
65
72
|
async def insert_group(
|
66
73
|
data: GroupData, user_token_data: AccessTokenData = Depends(access_token_scheme)
|
67
74
|
):
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
75
|
+
with tracer.start_as_current_span("authorizer.is_having_permission"):
|
76
|
+
if not await authorizer.is_having_permission(
|
77
|
+
user_token_data.user_id, "auth:group:insert"
|
78
|
+
):
|
79
|
+
raise HTTPAPIException(403, "Unauthorized")
|
72
80
|
try:
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
81
|
+
with tracer.start_as_current_span("auth.rpc.auth_insert_group"):
|
82
|
+
result_dict = await rpc_caller.call(
|
83
|
+
"auth_insert_group",
|
84
|
+
data=data.model_dump(),
|
85
|
+
user_token_data=user_token_data.model_dump(),
|
86
|
+
)
|
87
|
+
return Group(**result_dict)
|
79
88
|
except Exception as e:
|
80
89
|
raise HTTPAPIException(error=e)
|
81
90
|
|
@@ -85,18 +94,20 @@ def register_api(
|
|
85
94
|
data: GroupData,
|
86
95
|
user_token_data: AccessTokenData = Depends(access_token_scheme),
|
87
96
|
):
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
97
|
+
with tracer.start_as_current_span("authorizer.is_having_permission"):
|
98
|
+
if not await authorizer.is_having_permission(
|
99
|
+
user_token_data.user_id, "auth:group:update"
|
100
|
+
):
|
101
|
+
raise HTTPAPIException(403, "Unauthorized")
|
92
102
|
try:
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
103
|
+
with tracer.start_as_current_span("auth.rpc.auth_update_group"):
|
104
|
+
result_dict = await rpc_caller.call(
|
105
|
+
"auth_update_group",
|
106
|
+
id=id,
|
107
|
+
data=data.model_dump(),
|
108
|
+
user_token_data=user_token_data.model_dump(),
|
109
|
+
)
|
110
|
+
return Group(**result_dict)
|
100
111
|
except Exception as e:
|
101
112
|
raise HTTPAPIException(error=e)
|
102
113
|
|
@@ -104,14 +115,18 @@ def register_api(
|
|
104
115
|
async def delete_group(
|
105
116
|
id: str, user_token_data: AccessTokenData = Depends(access_token_scheme)
|
106
117
|
):
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
118
|
+
with tracer.start_as_current_span("authorizer.is_having_permission"):
|
119
|
+
if not await authorizer.is_having_permission(
|
120
|
+
user_token_data.user_id, "auth:group:delete"
|
121
|
+
):
|
122
|
+
raise HTTPAPIException(403, "Unauthorized")
|
111
123
|
try:
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
124
|
+
with tracer.start_as_current_span("auth.rpc.auth_delete_group"):
|
125
|
+
result_dict = await rpc_caller.call(
|
126
|
+
"auth_delete_group",
|
127
|
+
id=id,
|
128
|
+
user_token_data=user_token_data.model_dump(),
|
129
|
+
)
|
130
|
+
return Group(**result_dict)
|
116
131
|
except Exception as e:
|
117
132
|
raise HTTPAPIException(error=e)
|
@@ -8,6 +8,9 @@ from module.auth.component import Authorizer
|
|
8
8
|
from module.auth.integration import access_token_scheme
|
9
9
|
from module.auth.schema.permission import Permission, PermissionData, PermissionResult
|
10
10
|
from module.auth.schema.token import AccessTokenData
|
11
|
+
from opentelemetry import trace
|
12
|
+
|
13
|
+
tracer = trace.get_tracer(__name__)
|
11
14
|
|
12
15
|
|
13
16
|
def register_api(
|
@@ -26,20 +29,22 @@ def register_api(
|
|
26
29
|
offset: int = 0,
|
27
30
|
user_token_data: AccessTokenData = Depends(access_token_scheme),
|
28
31
|
):
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
32
|
+
with tracer.start_as_current_span("authorizer.is_having_permission"):
|
33
|
+
if not await authorizer.is_having_permission(
|
34
|
+
user_token_data.user_id, "auth:permission:get"
|
35
|
+
):
|
36
|
+
raise HTTPAPIException(403, "Unauthorized")
|
33
37
|
try:
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
38
|
+
with tracer.start_as_current_span("auth.rpc.auth_get_permission"):
|
39
|
+
result_dict = await rpc_caller.call(
|
40
|
+
"auth_get_permission",
|
41
|
+
keyword=keyword,
|
42
|
+
criterion={},
|
43
|
+
limit=limit,
|
44
|
+
offset=offset,
|
45
|
+
user_token_data=user_token_data.model_dump(),
|
46
|
+
)
|
47
|
+
return PermissionResult(**result_dict)
|
43
48
|
except Exception as e:
|
44
49
|
raise HTTPAPIException(error=e)
|
45
50
|
|
@@ -47,17 +52,19 @@ def register_api(
|
|
47
52
|
async def get_permission_by_id(
|
48
53
|
id: str, user_token_data: AccessTokenData = Depends(access_token_scheme)
|
49
54
|
):
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
55
|
+
with tracer.start_as_current_span("authorizer.is_having_permission"):
|
56
|
+
if not await authorizer.is_having_permission(
|
57
|
+
user_token_data.user_id, "auth:permission:get_by_id"
|
58
|
+
):
|
59
|
+
raise HTTPAPIException(403, "Unauthorized")
|
54
60
|
try:
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
+
with tracer.start_as_current_span("auth.rpc.auth_get_permission_by_id"):
|
62
|
+
result_dict = await rpc_caller.call(
|
63
|
+
"auth_get_permission_by_id",
|
64
|
+
id=id,
|
65
|
+
user_token_data=user_token_data.model_dump(),
|
66
|
+
)
|
67
|
+
return Permission(**result_dict)
|
61
68
|
except Exception as e:
|
62
69
|
raise HTTPAPIException(error=e)
|
63
70
|
|
@@ -66,17 +73,19 @@ def register_api(
|
|
66
73
|
data: PermissionData,
|
67
74
|
user_token_data: AccessTokenData = Depends(access_token_scheme),
|
68
75
|
):
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
76
|
+
with tracer.start_as_current_span("authorizer.is_having_permission"):
|
77
|
+
if not await authorizer.is_having_permission(
|
78
|
+
user_token_data.user_id, "auth:permission:insert"
|
79
|
+
):
|
80
|
+
raise HTTPAPIException(403, "Unauthorized")
|
73
81
|
try:
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
82
|
+
with tracer.start_as_current_span("auth.rpc.auth_insert_permission"):
|
83
|
+
result_dict = await rpc_caller.call(
|
84
|
+
"auth_insert_permission",
|
85
|
+
data=data.model_dump(),
|
86
|
+
user_token_data=user_token_data.model_dump(),
|
87
|
+
)
|
88
|
+
return Permission(**result_dict)
|
80
89
|
except Exception as e:
|
81
90
|
raise HTTPAPIException(error=e)
|
82
91
|
|
@@ -86,18 +95,20 @@ def register_api(
|
|
86
95
|
data: PermissionData,
|
87
96
|
user_token_data: AccessTokenData = Depends(access_token_scheme),
|
88
97
|
):
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
98
|
+
with tracer.start_as_current_span("authorizer.is_having_permission"):
|
99
|
+
if not await authorizer.is_having_permission(
|
100
|
+
user_token_data.user_id, "auth:permission:update"
|
101
|
+
):
|
102
|
+
raise HTTPAPIException(403, "Unauthorized")
|
93
103
|
try:
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
104
|
+
with tracer.start_as_current_span("auth.rpc.auth_update_permission"):
|
105
|
+
result_dict = await rpc_caller.call(
|
106
|
+
"auth_update_permission",
|
107
|
+
id=id,
|
108
|
+
data=data.model_dump(),
|
109
|
+
user_token_data=user_token_data.model_dump(),
|
110
|
+
)
|
111
|
+
return Permission(**result_dict)
|
101
112
|
except Exception as e:
|
102
113
|
raise HTTPAPIException(error=e)
|
103
114
|
|
@@ -105,16 +116,18 @@ def register_api(
|
|
105
116
|
async def delete_permission(
|
106
117
|
id: str, user_token_data: AccessTokenData = Depends(access_token_scheme)
|
107
118
|
):
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
119
|
+
with tracer.start_as_current_span("authorizer.is_having_permission"):
|
120
|
+
if not await authorizer.is_having_permission(
|
121
|
+
user_token_data.user_id, "auth:permission:delete"
|
122
|
+
):
|
123
|
+
raise HTTPAPIException(403, "Unauthorized")
|
112
124
|
try:
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
125
|
+
with tracer.start_as_current_span("auth.rpc.auth_delete_permission"):
|
126
|
+
result_dict = await rpc_caller.call(
|
127
|
+
"auth_delete_permission",
|
128
|
+
id=id,
|
129
|
+
user_token_data=user_token_data.model_dump(),
|
130
|
+
)
|
131
|
+
return Permission(**result_dict)
|
119
132
|
except Exception as e:
|
120
133
|
raise HTTPAPIException(error=e)
|
zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/entity/user/api.py
CHANGED
@@ -11,6 +11,9 @@ from module.auth.integration import access_token_scheme, bearer_token_scheme
|
|
11
11
|
from module.auth.schema.request import IsAuthorizedRequest, RefreshTokenRequest
|
12
12
|
from module.auth.schema.token import AccessTokenData, TokenResponse
|
13
13
|
from module.auth.schema.user import User, UserData, UserLogin, UserResult
|
14
|
+
from opentelemetry import trace
|
15
|
+
|
16
|
+
tracer = trace.get_tracer(__name__)
|
14
17
|
|
15
18
|
|
16
19
|
def register_auth_api(
|
@@ -35,10 +38,11 @@ def register_auth_api(
|
|
35
38
|
|
36
39
|
async def _create_token(data: UserLogin) -> TokenResponse:
|
37
40
|
try:
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
41
|
+
with tracer.start_as_current_span("auth.rpc.auth_create_token"):
|
42
|
+
token_response_dict = await rpc_caller.call(
|
43
|
+
"auth_create_token", login_data=data.model_dump()
|
44
|
+
)
|
45
|
+
return TokenResponse(**token_response_dict)
|
42
46
|
except Exception as e:
|
43
47
|
raise HTTPAPIException(error=e)
|
44
48
|
|
@@ -47,12 +51,13 @@ def register_auth_api(
|
|
47
51
|
data: RefreshTokenRequest, refresh_token: str = Depends(bearer_token_scheme)
|
48
52
|
) -> TokenResponse:
|
49
53
|
try:
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
54
|
+
with tracer.start_as_current_span("auth.rpc.auth_refresh_token"):
|
55
|
+
token_response_dict = await rpc_caller.call(
|
56
|
+
"auth_refresh_token",
|
57
|
+
refresh_token=refresh_token,
|
58
|
+
access_token=data.access_token,
|
59
|
+
)
|
60
|
+
return TokenResponse(**token_response_dict)
|
56
61
|
except Exception as e:
|
57
62
|
raise HTTPAPIException(error=e)
|
58
63
|
|
@@ -63,11 +68,12 @@ def register_auth_api(
|
|
63
68
|
) -> Mapping[str, str]:
|
64
69
|
try:
|
65
70
|
user_id = user_token_data.user_id
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
+
with tracer.start_as_current_span("auth.rpc.auth_is_user_authorized"):
|
72
|
+
return await rpc_caller.call(
|
73
|
+
"auth_is_user_authorized",
|
74
|
+
id=user_id,
|
75
|
+
permission_name=data.permission_names,
|
76
|
+
)
|
71
77
|
except Exception as e:
|
72
78
|
raise HTTPAPIException(error=e)
|
73
79
|
|
@@ -88,20 +94,22 @@ def register_api(
|
|
88
94
|
offset: int = 0,
|
89
95
|
user_token_data: AccessTokenData = Depends(access_token_scheme),
|
90
96
|
):
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
97
|
+
with tracer.start_as_current_span("authorizer.is_having_permission"):
|
98
|
+
if not await authorizer.is_having_permission(
|
99
|
+
user_token_data.user_id, "auth:user:get"
|
100
|
+
):
|
101
|
+
raise HTTPAPIException(403, "Unauthorized")
|
95
102
|
try:
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
103
|
+
with tracer.start_as_current_span("auth.rpc.auth_get_user"):
|
104
|
+
result_dict = await rpc_caller.call(
|
105
|
+
"auth_get_user",
|
106
|
+
keyword=keyword,
|
107
|
+
criterion={},
|
108
|
+
limit=limit,
|
109
|
+
offset=offset,
|
110
|
+
user_token_data=user_token_data.model_dump(),
|
111
|
+
)
|
112
|
+
return UserResult(**result_dict)
|
105
113
|
except Exception as e:
|
106
114
|
raise HTTPAPIException(error=e)
|
107
115
|
|
@@ -109,17 +117,19 @@ def register_api(
|
|
109
117
|
async def get_user_by_id(
|
110
118
|
id: str, user_token_data: AccessTokenData = Depends(access_token_scheme)
|
111
119
|
):
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
120
|
+
with tracer.start_as_current_span("authorizer.is_having_permission"):
|
121
|
+
if not await authorizer.is_having_permission(
|
122
|
+
user_token_data.user_id, "auth:user:get_by_id"
|
123
|
+
):
|
124
|
+
raise HTTPAPIException(403, "Unauthorized")
|
116
125
|
try:
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
126
|
+
with tracer.start_as_current_span("auth.rpc.auth_get_user_by_id"):
|
127
|
+
result_dict = await rpc_caller.call(
|
128
|
+
"auth_get_user_by_id",
|
129
|
+
id=id,
|
130
|
+
user_token_data=user_token_data.model_dump(),
|
131
|
+
)
|
132
|
+
return User(**result_dict)
|
123
133
|
except Exception as e:
|
124
134
|
raise HTTPAPIException(error=e)
|
125
135
|
|
@@ -127,17 +137,19 @@ def register_api(
|
|
127
137
|
async def insert_user(
|
128
138
|
data: UserData, user_token_data: AccessTokenData = Depends(access_token_scheme)
|
129
139
|
):
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
140
|
+
with tracer.start_as_current_span("authorizer.is_having_permission"):
|
141
|
+
if not await authorizer.is_having_permission(
|
142
|
+
user_token_data.user_id, "auth:user:insert"
|
143
|
+
):
|
144
|
+
raise HTTPAPIException(403, "Unauthorized")
|
134
145
|
try:
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
146
|
+
with tracer.start_as_current_span("auth.rpc.auth_insert_user"):
|
147
|
+
result_dict = await rpc_caller.call(
|
148
|
+
"auth_insert_user",
|
149
|
+
data=data.model_dump(),
|
150
|
+
user_token_data=user_token_data.model_dump(),
|
151
|
+
)
|
152
|
+
return User(**result_dict)
|
141
153
|
except Exception as e:
|
142
154
|
raise HTTPAPIException(error=e)
|
143
155
|
|
@@ -147,18 +159,20 @@ def register_api(
|
|
147
159
|
data: UserData,
|
148
160
|
user_token_data: AccessTokenData = Depends(access_token_scheme),
|
149
161
|
):
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
162
|
+
with tracer.start_as_current_span("authorizer.is_having_permission"):
|
163
|
+
if not await authorizer.is_having_permission(
|
164
|
+
user_token_data.user_id, "auth:user:update"
|
165
|
+
):
|
166
|
+
raise HTTPAPIException(403, "Unauthorized")
|
154
167
|
try:
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
168
|
+
with tracer.start_as_current_span("auth.rpc.auth_update_user"):
|
169
|
+
result_dict = await rpc_caller.call(
|
170
|
+
"auth_update_user",
|
171
|
+
id=id,
|
172
|
+
data=data.model_dump(),
|
173
|
+
user_token_data=user_token_data.model_dump(),
|
174
|
+
)
|
175
|
+
return User(**result_dict)
|
162
176
|
except Exception as e:
|
163
177
|
raise HTTPAPIException(error=e)
|
164
178
|
|
@@ -166,14 +180,18 @@ def register_api(
|
|
166
180
|
async def delete_user(
|
167
181
|
id: str, user_token_data: AccessTokenData = Depends(access_token_scheme)
|
168
182
|
):
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
183
|
+
with tracer.start_as_current_span("authorizer.is_having_permission"):
|
184
|
+
if not await authorizer.is_having_permission(
|
185
|
+
user_token_data.user_id, "auth:user:delete"
|
186
|
+
):
|
187
|
+
raise HTTPAPIException(403, "Unauthorized")
|
173
188
|
try:
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
189
|
+
with tracer.start_as_current_span("auth.rpc.auth_delete_user"):
|
190
|
+
result_dict = await rpc_caller.call(
|
191
|
+
"auth_delete_user",
|
192
|
+
id=id,
|
193
|
+
user_token_data=user_token_data.model_dump(),
|
194
|
+
)
|
195
|
+
return User(**result_dict)
|
178
196
|
except Exception as e:
|
179
197
|
raise HTTPAPIException(error=e)
|