Loading
Add an internal endpoint for a workflow's tool access policies
What does this MR do and why?
Duo Workflow Service gets a session's tool rules from the tool_access_policies claim in its token. This MR adds a second way to get them: an internal endpoint that returns the same rules for a workflow, so DWS can load them from the instance when the token doesn't carry the claim. The DWS side is in gitlab-org/modelops/applied-ml/code-suggestions/ai-assist!7740 (merged).
GET /api/v4/ai/duo_workflows/workflows/:id/tool_access_policiesreturnsallow,ask,denyandceilingfor the workflow. It only accepts requests through Workhorse, and only for the caller's own workflow, likeGET /:id. The namespace comes from the workflow, not from params. An optionalproject_id(the session's requested project) can only make the policy stricter, the same as on the claim path. It is ignored unless the caller can read the project and it is in the workflow's root namespace.- The resolution moves out of
ConnectionConfigServiceintoAi::DuoWorkflows::ToolAccessPoliciesService, so the endpoint and the claim resolve rules with the same code. The MCP pre-approvals here come from the workflow record, while the claim builds them from the request'sworkflow_definitionandai_catalog_item_version_id, soallowcan differ when those params don't match the record.connection_config_service_spec.rbpasses unchanged. - CI jobs get a placeholder
DUO_WORKFLOW_SERVICE_TOKENinstead of a usable token. The CLI only checks that the variable is set to pick CI mode, and never uses the value. This is behindduo_workflow_ci_service_token_placeholder, agitlab_com_deriskflag that is off by default and rolled out on GitLab.com first (#637141). Self-Managed gets the placeholder once the flag is removed.
The endpoint has no flag: it is read-only, and a flag rollback must not make DWS's request fail.
References
- #623436
How to set up and validate locally
- Start a Duo session and note the workflow ID.
- Through Workhorse, call
GET /api/v4/ai/duo_workflows/workflows/<id>/tool_access_policieswith the session user's token. It returns the same lists as the session'stool_access_policiesclaim, when the request params match the workflow. - The same call with another user's token returns
404, and a call straight to Puma returns403. - Add
?project_id=<id>for a readable project in the same group that denies another tool. That tool is added todeny. - Start a flow in CI and check the job's
DUO_WORKFLOW_SERVICE_TOKENisunused. The job still runs in CI mode.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist.
Edited by Rahul Barnwal