Security

Authentication

API key authentication and management in Spectron.

Every request to Spectron must carry a context or management API key as an HTTP Bearer token:

Authorization: Bearer <secret>

There are no session cookies and no OAuth on the data plane. Authentication is stateless: the server validates the key, resolves the principal, and enforces scope before handling the request.

PrincipalTypical scope floorCapabilities
ManagementUnrestrictedContext lifecycle, key provisioning, management REST
AgentOrg / agent / user pathsRead and write within the effective scope
SupervisorOrg-wide readRead across the org; limited write (for example reflection persist)

See Principals and Scope as security boundary.

On a fresh install, run bootstrap once (via Docker or your operator runbook):

docker compose exec spectron spectrond bootstrap \
--connection-string "ws://surrealdb:8000;root;root"

Stdout prints SPECTRON_MANAGEMENT_API_KEY and SPECTRON_API_KEY plus the new Context id. Store them immediately; secrets are not shown again.

Additional Context keys are minted via:

  • Management REST: POST /api/v1/contexts/{id}/keys/{name}

  • CLI: spectrond keys generate-key (CLI reference)

The public spectron CLI and generated SDKs expect:

VariablePurpose
SPECTRON_URLBase URL (for example http://localhost:9090)
SPECTRON_API_KEYContext-scoped end-user key
SPECTRON_CONTEXT_IDContext id in the path

Harness adapters also accept SPECTRON_BASE_URL and SPECTRON_CONTEXT per package READMEs in the Spectron repo clients/ tree.

MCP clients (Claude Desktop, Cursor, Claude Code) send the same Bearer token in the MCP transport config (Authorization: Bearer …). Run spectron mcp to print an install snippet.

Rotate a key in place without changing its id, principal binding, or grants:

POST /api/v1/contexts/{context_id}/keys/{key_name}/rotate?ttl_seconds=2592000
Authorization: Bearer <management-key>

The response includes a new secret (shown once). The previous secret stops working immediately — there is no overlap window. Omit ttl_seconds to inherit the key’s current expiry; pass it to reset expiry from now.

spectrond keys rotate <context_id> <key_name> --expires-in 2592000

Alternatively, mint a replacement key and delete the old one — see API keys and delegation.

Was this page helpful?