Skip to main content

Module auth

Module auth 

Source
Expand description

Enrollment (device flow), access tokens and lease renewal.

The instance’s Ed25519 key is its only long-lived secret: every access token is minted from a fresh signed assertion and cached until shortly before it expires. Nothing here runs inside a tool call.

Structs§

EnrollmentToken
A pre-issued Host enrollment token (het_ and 64 hex digits) that a team admin handed out, e.g. through MDM. It enrolls this machine without a browser approval. The value is wiped on drop and never printed: its Debug shows the prefix only, and no error names it.
Session
A connected instance: its record, verified lease and keys.
SetupAnnouncement
The project an engine names at connect (C0 2.1 device setup): the checkout’s folder name and the remote it sees, plus what it shares.

Constants§

ENROLLMENT_TOKEN_PREFIX
The plaintext prefix of a pre-issued Host enrollment token.
ENROLLMENT_TOKEN_UNUSABLE
Why a Cloud refused an enrollment token, in the words a person acts on.

Functions§

announce_setup
Step 1b (C0 2.1): name the project and what this machine shares, so the approval page asks “Share this project” too. Only when the Cloud offers it; false when it did not take it (the terminal then asks, as before).
complete_enrollment
Verify an enrollment answer against the root key and persist it.
engine_os
enroll_with_token
Enroll this machine with a pre-issued enrollment token (no browser): one POST /v1/device/token with the token as device_code, then the enrollment is verified and persisted exactly as after a device approval.
finish_device_flow
Step 2: poll until the user approved (or the code expired), then verify and persist the enrollment. sleep is injectable for tests.
start_device_flow
Step 1: ask Cloud for a device code; label is the user’s --label, if any (the approval page shows it, Cloud task #11).
start_device_flow_for
Step 1 for cloud connect [--trial]: trial names the plan whose one-step trial the browser starts (None: a plain sign-in, whose request is exactly the one older Clouds know).
trial_refusal
A trial request an older Cloud refused for its unknown members (400 invalid_request) is CloudError::TrialUnsupported: it is never sent again without them, so nobody signs in thinking a trial started.

Type Aliases§

SharingAnswer
What the device approval answered beyond the enrollment: the page’s answer to “Share this project” (C0 2.1). None: the page did not ask (no setup, or an older Cloud); Some(None): an older page approved it.