// CONTENTS Part 03 · Core engine

// PART 03

OAuth, directory, and sandbox

Chapter 15 / 56 2 min read English Part 03 of 14

Identity, external OAuth, and the sandbox are three separate subsystems that are often confused. This page states what each one is, with the routes and crates that implement them.

Directory (Zitadel)

The directory is the identity provider. No passwords are stored inside General Bots; authentication delegates to the directory service, and botserver keeps local user references keyed by the directory identity.

Concern Implementation
Directory client, organizations, groups, provisioning botserver/crates/botcoredirectory/ (client/, organizations.rs, groups/, provisioning.rs, auth_routes/)
Host-side operations botserver/src/core/directory/
Local role resolution botserver/src/security/user_role.rs (resolve_user_role)
Cloud login verification Zitadel v2 sessions check before any token is issued

OAuth (outbound, to external providers)

The botcoreoauth crate implements OAuth flows for external providers a bot connects to. The real routes are:

GET /auth/oauth/providers              # list configured providers
GET /auth/oauth/:provider              # start the flow
GET /auth/oauth/:provider/callback     # handle the provider redirect

(/auth itself serves static pages from the UI path — run_axum_server.rs nests a ServeDir there.) Per-user OAuth account connections, including the ChatGPT-plan connect with PKCE, are handled in botserver/src/core/ai_accounts_chatgpt/ with pending states held for 15 minutes and tokens stored in Vault on success.

What this is not: /auth/login, /auth/logout and /auth/validate from older documentation do not exist as botserver routes. Login lives on the login UI (port 5000) and /api/auth/* endpoints (see below).

/api/auth/* and anonymous access

Surface Behavior
POST /api/auth/cloud-sso, GET /api/auth/suite-sso, POST /api/auth/unified-login registered in src/main_module/routes/api_setup.rs (see the generated reference for the full family)
POST /api/auth/2fa/verify, /api/auth/2fa/resend two-factor helpers listed in the API command catalog
Anonymous auth src/main_module/routes/anonymous_auth.rs — resolves WS tokens, and defines the anonymous paths the middleware allows (health, public catalog, channel webhooks)
WS identity resolution token (cookie or query), then user_id, then a guest record — each handshake logs which of the three it used

Sandbox (code execution)

Two sandboxes exist, for different jobs:

Sandbox What it does Where
Legacy exec endpoint POST /api/v1/sandbox/exec (botagent crate) runs short-lived code in an ephemeral container with resource limits and network deny-by-default; accepts a JWT or an organization API key botserver/crates/botagent/src/lib.rs
Code sandbox previews generated HTML/CSP previews for chat answers; a signed URL, one-hour clamps, Drive as the durable copy; status endpoint /api/sandbox/status/:hash reports fresh / expired / interrupted_by_restart botserver/src/core/bot/sandbox/, botbasic_ai/src/keywords/code_sandbox/

The sandbox is deliberately not a general compute service: execution is bounded, previews expire, and only Drive keeps the bytes.

  • Authentication and authorization — tokens, CSRF, session storage.
  • RBAC and secrets — role resolution and the Vault layout.
  • Browser and computer use — the agentic use of a browser, which is a different mechanism from the sandbox above.

Found a mistake? Open an issue · All books

// SEARCH ESC
Pagefind · 236 pages · 4 books Enter to open ↑ ↓ to move