Fleet docs v0.2.0-rc.448

Sign-in

Five sequences: the first admin, fleet login, the page, a worker's token, and a node join. Each step was checked against the code named under the diagram.

First admin: bootstrap code

Code: fleet/deploy/install.sh, fleet/internal/server/wire_tokens.go, fleet/internal/api/tokens.go (bootstrapUser), fleet/internal/usertoken/usertoken.go.

The admin row has a login and no subject until the first sign-in. Thus, a plain fleet login with the same GitHub login also binds it, without the code (member in fleet/internal/api/tokens.go). This is the same rule that binds every member at first sign-in.

fleet login: device flow

Code: fleet/internal/cli/login.go, fleet/internal/api/tokens.go. fleet has no device endpoints of its own. fleet login --paste takes a token made on the page and checks it with GET /v1/me.

The page: through the proxy and dex

Code: fleet/deploy/examples/signin/ (Caddyfile, oauth2-proxy.cfg), fleet/internal/authn/authn.go (identityToken), fleet/internal/web/index.html. fleet trusts no proxy cookie and no X-Forwarded header. It checks the identity token itself.

The proxy session must not outlive the identity token (set cookie_expire lower than the token's life). If it does, the proxy gives the page, but /api/state answers 401. The page repairs this itself: see the panels. It knows that a proxy is there when oauth2/userinfo answers 200. The sign-out path is oauth2/sign_out?rd=<the page's path>.

A worker's turn token

Code: fleet/internal/token/token.go, fleet/internal/node/coordinator.go, fleet/internal/creds/keeper.go, fleet/internal/contextblock/contextblock.go, fleet/internal/api/reports.go.

  • The token is for the agent, not for one turn. The server computes it again each time. It does not store it.
  • Only the server's Keeper refreshes a Claude login. A turn gets an access token only.

A node join

Code: fleet/internal/cli/node.go, fleet/internal/api/nodes.go, fleet/internal/node/tokens.go, fleet/internal/node/agent.go, fleet/internal/node/coordinator.go.