Authentication and security
Understand the local launch exchange, session header, account token and origin protections.
Two local credentials, two jobs
| Credential | Purpose | Where it comes from |
|---|---|---|
| Launch token | One-time bootstrap credential for /api/session/exchange | The local desktop or browser launch flow |
| Session token | Authorises protected local API calls | Returned by the exchange endpoint; keep in memory |
| Account token | Authorises account-backed hosted AI and entitlement checks | An authenticated OpenSS desktop account flow; not created by this API |
Bootstrap sequence
- 01Receive
The local process constructs the launch URL or passes a launch token to its interface. Treat the token as a secret.
- 02Exchange
POST {baseUrl}/api/session/exchange with {launchToken}. The token is one-use and expires after five minutes.
- 03Attach
Send X-OpenSS-Session on every protected API request.
- 04Expire
Local session tokens are valid for eight hours or until the engine shuts down and invalidates them.
Required headers
X-OpenSS-Session: <session-token>
X-OpenSS-Account-Token: <account-token> # hosted AI, Pro context or provider-key routes
Content-Type: application/jsonAccount-backed routes
Hosted AI at POST /api/hosted-ai/respond requires X-OpenSS-Account-Token and forwards it to the OpenSS account backend. Provider-key routes and persistent chat context perform their own Pro entitlement checks. The local API does not mint, refresh or reveal account credentials.
Origin and network boundary
- The engine accepts only 127.0.0.1 binding; run_gui rejects another host.
- CORS allows the engine origin and explicitly configured packaged origins, not arbitrary websites.
- API requests with an unapproved Origin or Referer receive INVALID_ORIGIN.
- Request bodies are capped at 12 MiB. Captured image bytes are capped at 6 MiB and must be valid PNG, JPEG or WebP data.
- OpenAPI, Swagger UI and ReDoc are disabled. The documented contract is intentionally curated instead of discoverable through a public schema.
Safe client behavior
const response = await fetch(baseUrl + "/api/version");
// Keep tokens outside URLs, logs and persisted browser storage.
const sessionToken = exchange.sessionToken;
const headers = { "X-OpenSS-Session": sessionToken };OpenSS/src/openss/gui/server.py and schemas.py.