Bots and Connected apps
Device-code bot sign-in, MCP OAuth Connect, bearer keys, Gatekeep invites, and connected app history.
Bots and Connected apps
Bots (agents) sign in on Account with a device code flow or MCP OAuth Connect. Humans own every bot. Connected apps track which first-party apps a person has signed into via handoff, plus MCP client grants.
Three ways to reach Admin MCP
| Path | Who | How |
|---|---|---|
| Cursor Connect (OAuth) | IDE / MCP clients | Discover PRM on Admin → Auth AS → browser consent → zxoat_ access token |
| Device code | Headless bots | Account /api/device/* → human /device → zxmcp_ bot key |
| Paste bearer | Manual / legacy | Agentic account token from Admin ZiX MCP hub → Authorization: Bearer zxmcp_… |
Admin /api/mcp accepts both zxoat_ (OAuth) and zxmcp_ (agent keys). Effective permissions are always scopes/grants ∩ owner RBAC.
MCP OAuth Connect (Auth AS)
Account (auth.ziteox.com) is the shared Authorization Server. Admin is the first Resource Server.
sequenceDiagram
participant Cursor
participant Admin as Admin_RS
participant Auth as Auth_AS
participant Human
Cursor->>Admin: GET /api/mcp no token
Admin-->>Cursor: 401 WWW-Authenticate PRM
Cursor->>Admin: GET /.well-known/oauth-protected-resource
Admin-->>Cursor: authorization_servers Auth
Cursor->>Auth: discovery + DCR + authorize
Auth->>Human: login MFA consent
Human-->>Auth: Approve
Auth-->>Cursor: code then tokens
Cursor->>Admin: MCP with Bearer zxoat_Key URLs:
- Admin PRM:
https://admin.ziteox.com/.well-known/oauth-protected-resource - Auth AS metadata:
https://auth.ziteox.com/.well-known/oauth-authorization-server - Authorize / token / register:
https://auth.ziteox.com/oauth/* - Resource indicator:
https://admin.ziteox.com/api/mcp
Tables: core.agent_clients, core.agent_grants, core.oauth_authorization_codes, core.oauth_access_tokens, core.oauth_refresh_tokens.
People can revoke MCP client grants at auth.ziteox.com/account/apps (MCP clients section).
Opting in another product later
- Expose MCP on that host (e.g.
/api/mcp). - Serve PRM naming Auth as
authorization_serversand the product MCP URL asresource. - Make PRM session-optional (no HTML sign-in redirect).
- On 401, send
WWW-Authenticatewithresource_metadata. - Validate
zxoat_with audience = that resource (reuse@ziteox/auth/oauth).
Connecting to Auth alone does not expose Admin tools — each product remains its own MCP resource.
Device code flow (bots)
Bots do not use password login. They use RFC 8628-style device authorization on Account:
- Bot calls
POST /api/device/codewith aclient_nameand requestedscope - Account returns a
device_code, a shortuser_code, and a verification URL - A human opens
auth.ziteox.com/device, enters the user code, and approves (two-step / AAL2 required) - Bot polls
POST /api/device/tokenwith thedevice_codeuntil it receives a bearer token once
Approving creates an agent account owned by that human. Bot permissions cannot exceed the owner’s current ceiling.
sequenceDiagram
participant Bot
participant Account as Account (auth.ziteox.com)
participant Human
Bot->>Account: POST /api/device/code
Account-->>Bot: device_code, user_code, verification_uri
Bot->>Account: POST /api/device/token (poll)
Account-->>Bot: authorization_pending
Human->>Account: Open /device, enter user_code, approve (AAL2)
Account->>Account: Provision bot under human owner
Bot->>Account: POST /api/device/token (poll)
Account-->>Bot: access_token (bearer, once)Bot keys and /api/mcp
On successful device poll (or Admin MCP hub issue), Account/Admin issues a bot key: a bearer token used against Admin’s MCP endpoint (/api/mcp).
How checks work (no values — shape only):
- Tokens are generated with a fixed prefix plus random material; only a SHA-256 hash is stored (
mcp_service_tokens/ identity token store) - Admin validates the
Authorization: Bearer …header withresolveMcpAgentAuth→ OAuth (zxoat_) orvalidateAgentToken(zxmcp_) - Lookup is by hash; then the code rejects revoked or expired tokens, disabled agents, missing owners, and inactive owners
- Effective permissions are the agent’s grants capped by the owner’s current permissions
- Successful use updates
last_used_at
Treat bot keys like secrets: show once at issue time, never commit or log the raw value.
Bot invites and Gatekeep
When a bot proposes inviting a client (MCP tool path), Admin does not send email or create an invite row immediately. It opens a Gatekeep approval (invite_client). A human must approve; the executor then issues the invite under the approving person. Staff / admin role invites from bots are blocked.
Connected apps (first-party handoff)
Table core.app_connections (migration 20261101000000_app_connections.sql) records which apps a user has signed into via Account handoff:
| Column | Meaning |
|---|---|
user_id | Auth user |
app_key | App from core.apps (e.g. admin, client) |
first_connected_at | First successful handoff for that app |
last_used_at | Most recent successful handoff |
On each successful POST /api/handoff/token exchange, Account calls recordAppConnection: insert once (keeps first connected), then bump last_used_at.
People can review the list at auth.ziteox.com/account/apps (first connected and last used per app). That page also links to /device for connecting bots and lists MCP OAuth grants.