1111from tracecat .agent .service import AgentManagementService
1212from tracecat .auth .credentials import RoleACL
1313from tracecat .auth .types import AccessLevel , Role
14+ from tracecat .authz .controls import require_scope
1415from tracecat .db .dependencies import AsyncDBSession
1516from tracecat .exceptions import TracecatNotFoundError
1617
4647
4748
4849@router .get ("/models" )
50+ @require_scope ("agent:read" )
4951async def list_models (
5052 * ,
5153 role : OrganizationUserRole ,
@@ -57,6 +59,7 @@ async def list_models(
5759
5860
5961@router .get ("/providers" )
62+ @require_scope ("agent:read" )
6063async def list_providers (
6164 * ,
6265 role : OrganizationUserRole ,
@@ -68,6 +71,7 @@ async def list_providers(
6871
6972
7073@router .get ("/providers/status" )
74+ @require_scope ("agent:read" )
7175async def get_providers_status (
7276 * ,
7377 role : OrganizationUserRole ,
@@ -79,6 +83,7 @@ async def get_providers_status(
7983
8084
8185@router .get ("/providers/configs" )
86+ @require_scope ("agent:read" )
8287async def list_provider_credential_configs (
8388 * ,
8489 role : OrganizationAdminUserRole ,
@@ -90,6 +95,7 @@ async def list_provider_credential_configs(
9095
9196
9297@router .get ("/providers/{provider}/config" )
98+ @require_scope ("agent:read" )
9399async def get_provider_credential_config (
94100 * ,
95101 provider : str ,
@@ -108,6 +114,7 @@ async def get_provider_credential_config(
108114
109115
110116@router .post ("/credentials" , status_code = status .HTTP_201_CREATED )
117+ @require_scope ("agent:execute" )
111118async def create_provider_credentials (
112119 * ,
113120 params : ModelCredentialCreate ,
@@ -127,6 +134,7 @@ async def create_provider_credentials(
127134
128135
129136@router .put ("/credentials/{provider}" )
137+ @require_scope ("agent:update" )
130138async def update_provider_credentials (
131139 * ,
132140 provider : str ,
@@ -152,6 +160,7 @@ async def update_provider_credentials(
152160
153161
154162@router .delete ("/credentials/{provider}" )
163+ @require_scope ("agent:delete" )
155164async def delete_provider_credentials (
156165 * ,
157166 provider : str ,
@@ -165,6 +174,7 @@ async def delete_provider_credentials(
165174
166175
167176@router .get ("/default-model" )
177+ @require_scope ("agent:read" )
168178async def get_default_model (
169179 * ,
170180 role : OrganizationUserRole ,
@@ -176,6 +186,7 @@ async def get_default_model(
176186
177187
178188@router .put ("/default-model" )
189+ @require_scope ("agent:update" )
179190async def set_default_model (
180191 * ,
181192 model_name : str ,
@@ -200,6 +211,7 @@ async def set_default_model(
200211
201212
202213@router .get ("/workspace/providers/status" )
214+ @require_scope ("agent:read" )
203215async def get_workspace_providers_status (
204216 * ,
205217 role : WorkspaceUserRole ,
0 commit comments