Skip to content

feat(agent-service): scope agents to their verified owner - #9580

Merged
bobbai00 merged 4 commits into
apache:mainfrom
bobbai00:feat/agent-ownership
Nov 25, 2026
Merged

bobbai00 merged 4 commits into
apache:mainfrom
bobbai00:feat/agent-ownership

Conversation

@bobbai00

@bobbai00 bobbai00 commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

Each user now sees and opens only their own agents, and a login token needs a valid signature.

Before After
Agent list (GET /api/agents) Every user's agents The caller's only
Another user's agent, by id or websocket Opens: its chat is readable, and prompts use the owner's token 404 "Agent not found", as for an unknown id
No token, or a forged one Accepted: the only check read the expiry 401

Another user's agent. e2e-reader opens "Penguin species comparison", which texera shared read-only. Before, the panel lists texera's "Penguin analyst" and shows its chat, texera's question marked "You":

Before: e2e-reader's panel shows texera's Penguin analyst and its chat

After, it lists only e2e-reader's own agent:

After: e2e-reader's panel shows only Plot helper
  • The agent service checks the HS256 signature with AUTH_JWT_SECRET, read as the dashboard service reads it (auth.conf's default, lowercased, never random). Kubernetes passes it in.
  • Each agent records its creator, and every route and the websocket check the caller against it.
  • The frontend puts the token in the agent websocket's query, like the workflow websocket.

#9043 adds a gateway check and will follow this PR, taking over the token check.

Any related issues, documentation, discussions?

Closes #5268

Agent ids stay sequential: a guessed id gets the same 404 as a missing one.

How was this PR tested?

Agent-service tests cover every route and the websocket with another user's token, no token and forged tokens, and how the secret is read. Also tested in headless Chromium as two users with a real model. The second sees none of the first's agents or chat, and the owner's agent still builds and executes a workflow.

Was this PR authored or co-authored using generative AI tooling?

Generated-by: Claude Code (Claude Fable 5.2, Claude Opus 5.5)

@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Automated Reviewer Suggestions

Based on the git blame history of the changed files, we recommend the following reviewers:

  • Contributors with relevant context: @CaroFernando, @aglinxinyuan, @dzueck
    You can notify them by mentioning @CaroFernando, @aglinxinyuan, @dzueck in a comment.

@github-actions github-actions Bot added feature frontend Changes related to the frontend GUI infra agent-service labels Nov 20, 2026
@codecov-commenter

codecov-commenter commented Nov 20, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.69%. Comparing base (de3f021) to head (adac83e).

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #9580   +/-   ##
=========================================
  Coverage     91.68%   91.69%           
  Complexity     5132     5132           
=========================================
  Files          1305     1306    +1     
  Lines         58252    58296   +44     
  Branches       7604     7605    +1     
=========================================
+ Hits          53408    53453   +45     
  Misses         2937     2937           
+ Partials       1907     1906    -1     
Flag Coverage Δ *Carryforward flag
access-control-service 77.44% <ø> (ø) Carriedforward from de3f021
agent-service 99.56% <100.00%> (+<0.01%) ⬆️
amber 85.76% <ø> (ø) Carriedforward from de3f021
computing-unit-managing-service 63.83% <ø> (ø) Carriedforward from de3f021
config-service 87.50% <ø> (ø) Carriedforward from de3f021
file-service 82.16% <ø> (ø) Carriedforward from de3f021
frontend 96.44% <100.00%> (+<0.01%) ⬆️
notebook-migration-service 83.77% <ø> (ø) Carriedforward from de3f021
pyamber 98.38% <ø> (ø) Carriedforward from de3f021
result-service 86.48% <ø> (ø) Carriedforward from de3f021
workflow-compiling-service 80.90% <ø> (ø) Carriedforward from de3f021

*This pull request uses carry forward flags. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@bobbai00
bobbai00 marked this pull request as ready for review November 21, 2026 07:39
@bobbai00
bobbai00 requested a review from kunwp1 November 23, 2026 03:30

@kunwp1 kunwp1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some comments.

Comment thread agent-service/src/api/auth-api.ts Resolved
Comment thread agent-service/src/server.spec.ts Resolved
Comment thread agent-service/src/server.ts Resolved
Comment thread agent-service/src/server.ts Resolved
@bobbai00

Copy link
Copy Markdown
Contributor Author

@sshiv012 could you take a look? This fixes #5268, item 2 in #9568: each user now sees and opens only their own agents. #9043, for #5561, follows it and adds the gateway check.

@bobbai00
bobbai00 force-pushed the feat/agent-ownership branch from f35dce3 to 5ce9e7f Compare November 24, 2026 06:54
Any caller could list every user's agents and read or drive any of them: the
agent list was not per user, routes and the websocket looked an agent up by id
alone, and the one token check, at creation, only decoded the token.

The service now verifies a token's HS256 signature with the secret the
dashboard service signs it with (AUTH_JWT_SECRET, defaulting to auth.conf's
value as the backend does) before trusting its claims. Each agent records the
user who created it. Every /agents route requires the token, the list returns
the caller's agents only, and a route or websocket naming another user's
agent answers as for an agent that does not exist.

The frontend sends the token in the agent websocket's query, as the workflow
websocket does, and the Kubernetes chart passes the secret to the service.
Seven of the ownership tests timed out in CI. Their table rows had two
entries where the test takes three parameters, and Bun fills a missing
parameter with a `done` callback. With no dashboard service answering,
as in CI, the tests waited for that callback. Their requests also carried
a JSON content type without a body. Each row now names its body.
AuthConfig.scala lowercases AUTH_JWT_SECRET before signing, and treats
"random" as a request for a key of its own. The agent service used the
value as written, so a secret with a capital letter made it reject every
login token, and "random" started a service that could verify none.

The secret is now lowercased, and "random" stops the service at startup
with a message saying what to set instead.
Every route reaches its agent through getAgent(id, user), which serves
the agent to its owner alone, so the check holds whatever a route names
its parameter, and the guard only authenticates. verifyToken returns a
signed, unexpired token's user from one decode, in place of
validateToken and extractUserFromToken. The tests sign their tokens
with one shared helper, and the "created agent" log records the owner's
id.
@bobbai00
bobbai00 force-pushed the feat/agent-ownership branch from 435e4d2 to adac83e Compare November 24, 2026 23:02
@bobbai00
bobbai00 requested a review from kunwp1 November 24, 2026 23:06

@kunwp1 kunwp1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@bobbai00
bobbai00 added this pull request to the merge queue Nov 25, 2026
Merged via the queue into apache:main with commit 871b177 Nov 25, 2026
26 checks passed
@bobbai00
bobbai00 deleted the feat/agent-ownership branch November 25, 2026 08:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-service feature frontend Changes related to the frontend GUI infra

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add access control and per-user isolation to the agent service

3 participants