Repository navigation
Workspaces phase 2e: platform-only, workspace admins and the switcher (#277) - #320
Merged
Merged
Conversation
…#277) ctx.is_admin now takes in the owners and admins of the request's workspace, and DashboardAuthzMiddleware asks it. PLATFORM_ONLY_PATHS (migrations, server control, settings, system jobs, wizard and shop, users, audit retention, the template catalogue, reload all and binary builds) need a platform administrator, and the installation's pages check ctx.is_platform_admin; base.html and the pages hide their links and controls from everyone else. Agent features that run code on the server or read its environment are platform-only (shared/utils/platform_only.py): the code executor, stdio MCP servers, ${VAR} in the model endpoint and MCP config, and hardcoded agents, including a name with a folder in agents/. A workspace admin can't add one or change its defining part on create, update, rollback or template import; an agent import and a template sync skip the agent. At run time the code executor and stdio servers are refused to an agent outside the default workspace, on both runtimes. A2A goes through the proxy for a caller who may use the agent, its roles checked there. The dashboard session keeps the workspace chosen in the new switcher (GET /dashboard/api/workspaces, PUT .../current), shown with more than one workspace; a choice the caller lost falls back to the default. With one workspace every owner is a platform administrator, so an installation sees no change. test_client_contract.py is unchanged.
From the security review of phase 2e. A clone writes its suffix into the cloned
configs, so a suffix like ${MATE_SECRET_KEY} put a ${VAR} into an HTTP MCP URL, and
a quote could break out of the JSON; a clone or template could also give a workspace
admin a name with a folder in agents/, whose code then ran as their agent and whose
folder they could delete.
The suffix now holds letters, digits and underscores only. For a caller who is no
platform administrator a clone bumps a name with a code folder and refuses, before
writing anything, a rename that changes a platform-only feature of its source; a
template import refuses such a name before creating the project (409), and a
template sync skips the agent.
From the second security review of phase 2e, on code a workspace admin now reaches.
An agent name must be one ADK accepts, an identifier: create and rename answer 400
otherwise, an import skips the agent, and the agent server's start creates folders
for valid names only. A name like '..' or '/srv' made deleting the agent with
delete_folder=true run rmtree outside agents/; that route now goes through
_delete_agent_folder, which deletes only a folder right under agents/ named exactly
like the agent. An agent keeps a name it already has.
Moving a root agent to another project moved every agent whose parent_agents
matched an unescaped LIKE on its name, in any workspace, so a root named '%' took
every sub-agent of the installation. It now moves the sub-agents of its own
workspace that name it exactly, by the name it had before the update.
The platform-only ${VAR} check reads mcp_servers_config as the runtimes do, which
decode an entry's headers, args and env once more when it is a string, so a
placeholder spelled with JSON escapes there is seen. A new base URL beside a stored
key the request keeps without naming it is refused too: the caller types the key
again.
This was referenced Nov 3, 2026
antiv
added a commit
that referenced
this pull request
Nov 3, 2026
A review of phases 2a-2e together (cb8a218..b1e3fef) found these cross-workspace paths and 1.x differences; TestReviewOfPhase2 and test_a2a_routes cover each. - may_run_code() judges a config by its project_id. A subagent made by delegation has its parent's project and a name with no row, so it ran the code executor and stdio MCP servers for an agent outside the default workspace. - The Work Room title escapes agent, user and session id in the agent-server URL: httpx resolves '..' in a path, so a session id could name another workspace's session, read its first message and write its title. - A rating needs agent_name and a session of the caller with that agent; before, a rating with no agent skipped the workspace check, and one through an agent of A could point the eval pages at B's session. - Session detail and delete use the whole ADK key (app, user, id) and read only the checked session's events; the rated-answer pages read events by session and agent. - A widget visitor is a widget_<key id>_ id with the widget role, which only the server gives out (V017 gave it to the earlier visitors). Single sign-on and Users refuse ids starting widget_ and trigger_runner (is_reserved_user_id). - Each agent gets its own A2A task store, so tasks/get and tasks/cancel through one agent find none of another's. - A Slack team stays with the first workspace to connect it; the 409 says to ask a platform administrator. - The ${VAR} defining part is each place holding one, so editing an MCP server without a placeholder is no longer refused. - X-MATE-Workspace with a non-ASCII digit is a 404, not a 500. - The request context is made once a request: the middleware's is reused. The plan now ships phases 3 and 4 in 2.0.0 too, and records 2e (#320) and 2f. test_client_contract.py is unchanged and passes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase 2e of #277 (
documents/design/2.0-plan.md), the last PR of phase 2. Workspace owners and admins now administer their workspace, platform administrators keep the installation, and a switcher picks the workspace. With one workspace every owner is a platform administrator, so an installation sees no change apart from what is listed below.Workspace admins and platform administrators
ctx.is_adminnow covers the owners and admins of the request's workspace, andDashboardAuthzMiddlewareasks it.ctx.is_platform_adminis theadminrole.PLATFORM_ONLY_PATHSneed a platform administrator: migrations, server control, settings, system jobs, the wizard and shop, users, audit retention, the template catalogue, reload all and binary builds. The installation's pages checkctx.is_platform_admin, andbase.htmland the pages hide their links and controls from everyone else.What stays platform-only (
shared/utils/platform_only.py)These run code on the server or read its environment:
${VAR}inmodel_api_key,model_base_urlandmcp_servers_config;agents/.A workspace admin can't add one or change its defining part on create, update, rollback or template import (403). An agent import and a template sync skip the agent. At run time both runtimes refuse the code executor and stdio servers to an agent outside the default workspace.
Switcher
GET /dashboard/api/workspacesandPUT /dashboard/api/workspaces/current. The dashboard session keeps the chosen workspace, and a choice the caller has lost falls back to the default. The switcher only shows with more than one workspace.Security reviews
Two security reviews ran on this branch. Every finding is fixed here, with a test.
First review (afd756d):
${MATE_SECRET_KEY}put a${VAR}into an HTTP MCP URL, and a quote could break out of the JSON. A suffix now holds only letters, digits and underscores.agents/, whose code then ran as their agent. For a caller who isn't a platform administrator:Second review (ce1bc46):
headers,argsandenva second time, so"${VAR}"was only a placeholder after the check had passed.features_addednow decodes them the same way first...deleted withdelete_folder=truewouldrmtreethe installation. The delete route now goes through_delete_agent_folder, which only removesagents/<name>itself. The agent server skips a folder for an invalid legacy name at startup.LIKEacross the whole installation, so a root named%moved every sub-agent. It now escapes the name, matches the parent exactly and stays in the agent's original workspace.Left as they are, platform administrators only: the
rmtreeinwizard/cleanup.pyand name validation increate_agent_tool.Behaviour changes with one workspace
delete_folder=truedeletes no folder for a name that isn't one folder directly underagents/.Docs
gen_docs --checkpasses. Updated:docs/user/agents.md,templates.md,tools-and-mcp.mdandusers-and-roles.md, anddocs/dev/auth-and-access.md,code-executor.mdandlanggraph-runtime.md. These drift-listed guides still hold:docs/dev/a2a.mdanddocs/dev/architecture.md:server_control_service.pyonly skips a folder for an invalid name, and the proxy change is the A2A check described inauth-and-access.md.docs/dev/agent-runtime.mdanddocs/dev/writing-a-tool.md: the runtime guard is the one linemay_run_code, and tool construction is otherwise unchanged.docs/dev/alerts.md,docs/dev/template-format.mdanddocs/dev/trigger-engine.md:dashboard_server.pychanged only in the agent routes and in the platform-only checks. The template format and trigger and alert behaviour are the same.docs/dev/tracing.md: tracing is unchanged.docs/dev/documentation.md:docs.htmlonly hides links to platform-only pages.docs/user/triggers.md,docs/user/usage-and-audit.mdanddocs/user/settings.md: the templates only hide platform-only controls from workspace admins, and nothing changes for a platform administrator.Verification
Tests. The full suite passes: 1834 tests, 1 skipped.
test_client_contract.pyis unchanged.Mutation check. I removed each new check one at a time, and a test fails for every one except the exact-parent check in the propagation loop. The escaped
LIKEalready matches exactly, so that check is a second layer, as it is in the runtime.Local server. I created a temporary workspace with an owner who isn't a platform administrator and tried the reviews' attacks as that owner:
..,.,/tmp/x,a/b,%anda-bgot 400;${VAR}in string headers got 403;%root left all 33 sub-agents of the default workspace where they were;The switcher showed for the platform administrator only, and the owner saw only their workspace. The admin pages answered 200, the server log has no traceback, and cleanup left nothing behind.