Workspace access
A workspace is an ordinary web application. It knows nothing about platform users. Each worker runs a gateway, an Envoy next to its agent in the agent's pod, that serves every workspace of the worker on <id>.<domain> and has the agent authorize every request before passing it on. The agent asks the control plane over its link, and remembers the answer for a minute.
The flow
- Ticket. The UI calls
POST /v1/workspaces/{id}/sessionwith the path to land on. The API checks that the caller may access the workspace and returns the workspace URL with a ticket in theidekube_ticketquery parameter. The ticket is a signed token for the audiencews:<id>, valid for 60 seconds. - Check. For every request to a workspace host, Envoy calls the agent's ext_authz service. The agent takes the workspace id from the first label of the host. A workspace that does not run sends the visitor to
<external_url>/workspaces/<id>/open, which says why and offers to start it. A request without any credential is refused there and then. - Decision. Otherwise the agent asks the control plane with every credential the request carries: the ticket, the
idekube_wscookie, and theX-Idekube-Tokenheader. Any one of them admits the request when it is a valid token for this workspace, of an active user who owns it or holdsworkspace:manage, the workspace is not being deleted, and it runs on the worker that asks. A worker cannot vouch for another worker's workspaces. - Session cookie. When a ticket admitted the request, the response sets the
idekube_wscookie: a token for the same audience that lastsaccess.session_ttl_s. It isHttpOnly,SameSite=Lax,Securewhen the worker serves over HTTPS, and scoped to that workspace's host. - Without a session, a page request is redirected to
<external_url>/workspaces/<id>/openwith the original path in therdparameter. That page of the UI, which requires a platform sign-in, requests a new ticket for the same path and sends the browser back. Anything else, such as a script's request or a WebSocket, gets401.
Properties
- A session is bound to one workspace. The token's audience is
ws:<id>. A cookie from one workspace is rejected on another, and neither a ticket nor a workspace cookie is accepted by the API, whose access tokens have a different audience. - Workspaces cannot read each other's cookies: the cookie is host-only and each workspace has its own host.
- Pages of other sites cannot use them. All workspaces are hosts of one domain, and so of one site to a browser, which sends a user's cookie for a workspace with a request another workspace's page makes. The gateway refuses with
403a request to the sidecar (/.idekube/) or a WebSocket upgrade whoseOriginis neither the workspace's own host nor the platform's; a request without anOrigin, which no browser makes for these, is not concerned. - Decisions are remembered for one minute, refusals for ten seconds, per workspace and set of credentials. Revoking access (disabling a user, deleting a workspace) therefore takes up to a minute to reach requests that are already authorized.
- The control plane out of reach, e.g. as it is upgraded, means that what was allowed in the last quarter of an hour still stands, so that a user's session is not cut off, and anything new is answered with
503. Nothing is allowed by default when no decision was made. - Guessing is held back. Each address may make the control plane decide about ten new credentials a second; beyond that, the gateway answers
429. Envoy counts the address fromX-Forwarded-For, trusting as many proxies in front of it as the worker chart'sgateway.trustedHopssays, by default the ingress controller when there is one. - Public paths bypass all of this. Prefixes listed in a template's
public_paths, such as the SSH tunnel, are served without authorization. They match whole path segments (/pubcovers/pub/x, not/public), and paths are normalized before they are matched:/pub/../adminand/pub/..%2Fadminare not public. - Nothing reaches a workspace but through its gateway. Each start draws a new random access token. The workspace's container gets it as
IDEKUBE_ACCESS_TOKEN, which makes the image's nginx refuse every request without it, except/healthand the SSH tunnel; the gateway adds it to every request it passes on. Another pod that reaches the workspace's address directly gets401. The token is never sent to a browser. - All tokens are signed with
IDEKUBE_SECRET_KEY(HS256). Rotating the key ends every workspace session.
The platform's pages and the sidecar
Under /.idekube/ on its host, a workspace's gateway routes to the workspace's sidecar, which serves its files and the state of its tasks to the platform's pages, and to idk and the MCP server, which ask for them the same way. These requests are authorized like any other. The pages send a token for the workspace, from POST /v1/workspaces/{id}/token, valid for a quarter of an hour, in the X-Idekube-Token header, which the gateway removes before passing the request on; the gateway answers their CORS preflights for the platform's origin before anything asks for credentials. A download is a navigation instead: the page asks for a session URL of the file, whose ticket admits it, and the browser saves what the workspace sends.
The sidecar serves only requests that carry the workspace's access token, which only the gateway adds, and confines every path to the workspace's volumes, through which no symbolic link leads out. The platform's pages may call workspace hosts: the frontend's Content-Security-Policy allows the local worker's domain, and those listed in the chart's frontend.connectSources.
Activity
Every half a minute the agent reads from Envoy how many bytes each workspace's upstreams, the workspace and its sidecar, received and sent, and reports them. A workspace that exchanged at least access.activity_bytes (8 KiB by default) counts as in use. This covers page loads, the long-lived WebSockets of editors and terminals, and SSH through the tunnel alike, while the keep-alives of a tab nobody looks at stay below it.
The timestamps are buffered in Valkey. The access.sweep_idle job persists them once a minute and stops workspaces that have been idle for longer than their timeout.
Requirements this places on a worker's cluster
- The wildcard workspace domain must reach the gateway: through the cluster's ingress controller (
gateway.ingress.enabled, which any controller that passes WebSockets and forwardsX-Forwarded-Forcan serve), or through the gateway's own Service of typeLoadBalancerorNodePort, in which case the gateway terminates TLS itself withworkspaces.tlsSecret. platform.external_urlmust be set, or visitors without a session are sent nowhere useful.