Documentation
¶
Index ¶
- Constants
- Variables
- func DefaultLockPath(environment map[string]string) (string, error)
- func DefaultPath(environment map[string]string) (string, error)
- type Backend
- type Credential
- type LockGrant
- type LockPinConfirmation
- type LockRecord
- type LockScope
- type LockStore
- func (s LockStore) Forget(baseURL string) error
- func (s LockStore) Grant(scope LockScope, pin string, grant LockGrant, nowMs int64) error
- func (s LockStore) Pin(scope LockScope, pin string, confirmation LockPinConfirmation) error
- func (s LockStore) Prune(nowMs int64) error
- func (s LockStore) Read(baseURL, workspaceUUID string, nowMs int64) (LockRecord, error)
- func (s LockStore) Repair(scope LockScope, pin string, confirmation LockPinConfirmation) error
- func (s LockStore) Revoke(baseURL, workspaceUUID string) error
- func (s LockStore) Scopes() ([]string, error)
- func (s LockStore) Unpin(baseURL, workspaceUUID string) error
- type Store
Constants ¶
const ( // LockGrantLifetimeMs is the contract's hard eight-hour device deadline. // There is no sliding refresh and no remember-device setting. LockGrantLifetimeMs int64 = 8 * 60 * 60 * 1000 )
Variables ¶
var ( // ErrLockPinChanged reports a guest identity that differs from the pinned // one. It is never resolved automatically: the user re-pairs explicitly. ErrLockPinChanged = errors.New("workspace guest identity changed") // ErrLockPinUnknown reports that this device has never pinned this guest. ErrLockPinUnknown = errors.New("workspace guest identity is not pinned") // ErrLockStoreInvalid reports unusable on-disk state. It fails closed. ErrLockStoreInvalid = errors.New("workspace lock store is invalid") )
Functions ¶
func DefaultLockPath ¶ added in v0.1.1
DefaultLockPath places the lock store beside the credentials file, so one configuration directory holds everything a logout must clear.
Types ¶
type Backend ¶
type Backend interface {
Load(baseURL string) (Credential, error)
Save(credential Credential) error
Delete(baseURL string) error
Hosts() ([]string, error)
}
Backend is the credential storage contract. The file store is the only implementation today; a keychain backend would satisfy the same interface. Load and Delete are keyed by the normalized Control Plane base URL so a login to a second host never overwrites the first.
type Credential ¶
type Credential struct {
BaseURL string `json:"-"`
Token string `json:"token"`
AccountEmail string `json:"account_email,omitempty"`
ExpiresAt string `json:"expires_at,omitempty"`
}
Credential is one Control Plane token bound to the normalized base URL it was issued for. Tokens for different hosts never share an entry.
type LockGrant ¶ added in v0.1.1
type LockGrant struct {
DeviceSessionUUID string `json:"device_session_uuid"`
DeviceScalar []byte `json:"-"`
EncodedScalar string `json:"device_scalar"`
IssuedAtMs int64 `json:"issued_at"`
ExpiresAtMs int64 `json:"expires_at"`
BootUUID string `json:"boot_uuid"`
LockEpoch int64 `json:"lock_epoch"`
CredentialRevision int64 `json:"credential_revision"`
ActorSubjectUUID string `json:"actor_subject_uuid"`
MembershipUUID string `json:"membership_uuid"`
}
LockGrant is a live device session. DeviceScalar is the only private value the CLI writes to disk, and only until the grant's deadline.
type LockPinConfirmation ¶ added in v0.1.1
type LockPinConfirmation string
LockPinConfirmation records how the pin was established, so the CLI can be honest about a trust-on-first-use bootstrap rather than calling it verified.
const ( // LockPinTrustedProvisioning is a first, disclosed bootstrap. LockPinTrustedProvisioning LockPinConfirmation = "trusted-provisioning" // LockPinManualComparison is a pin the user compared against a trusted // device and accepted. LockPinManualComparison LockPinConfirmation = "manual-comparison" )
type LockRecord ¶ added in v0.1.1
type LockRecord struct {
OrganizationUUID string `json:"organization_uuid"`
AssignmentGeneration int64 `json:"assignment_generation"`
IdentityPin string `json:"identity_pin"`
Confirmation LockPinConfirmation `json:"confirmation"`
Grant *LockGrant `json:"grant,omitempty"`
}
LockRecord is one workspace assignment's client state.
func (LockRecord) Matches ¶ added in v0.1.1
func (r LockRecord) Matches(scope LockScope) bool
Matches reports whether this record was pinned for the same organization and assignment the guest is now presenting.
type LockScope ¶ added in v0.1.1
type LockScope struct {
BaseURL string
OrganizationUUID string
WorkspaceUUID string
AssignmentGeneration int64
}
LockScope names one workspace assignment on one Control Plane. A grant never crosses any of these four boundaries.
type LockStore ¶ added in v0.1.1
type LockStore struct {
Path string
}
LockStore is the owner-only JSON file backend for lock device state.
func (LockStore) Forget ¶ added in v0.1.1
Forget removes every record for one Control Plane, pins included. Logout calls it: a device grant must not outlive the session that established it.
func (LockStore) Grant ¶ added in v0.1.1
Grant installs a device session under an already pinned identity. It refuses a grant whose deadline exceeds the contract's eight hours.
func (LockStore) Pin ¶ added in v0.1.1
func (s LockStore) Pin(scope LockScope, pin string, confirmation LockPinConfirmation) error
Pin records the guest identity for this assignment. An existing pin is never silently replaced: a different one fails closed and requires explicit re-pairing, which also discards any grant held under the old identity.
func (LockStore) Prune ¶ added in v0.1.1
Prune removes grants that already expired. It runs on every command that touches the store, so a stale scalar is not left on disk indefinitely.
func (LockStore) Read ¶ added in v0.1.1
func (s LockStore) Read(baseURL, workspaceUUID string, nowMs int64) (LockRecord, error)
Read returns this workspace assignment's pinned identity and its live grant, if any. Expired grants, and grants issued in the future because the clock moved backwards, are dropped before the record is returned.
func (LockStore) Repair ¶ added in v0.1.1
func (s LockStore) Repair(scope LockScope, pin string, confirmation LockPinConfirmation) error
Repair replaces the pinned identity after the user explicitly accepted a new one. Every grant under the old identity is discarded.
func (LockStore) Revoke ¶ added in v0.1.1
Revoke drops one workspace's grant, keeping its pin. Locking, stopping or reassigning the workspace all reach this path.
type Store ¶
type Store struct {
Path string
}
Store is the owner-only JSON file backend.
func (Store) Delete ¶
Delete removes one host's credential. The file is removed once it holds no credentials at all. A missing entry is not an error.
func (Store) Load ¶
func (s Store) Load(baseURL string) (Credential, error)
Load returns the credential stored for baseURL, or fs.ErrNotExist when the file or that host's entry is absent.
func (Store) Save ¶
func (s Store) Save(credential Credential) error
Save stores the credential under its base URL, keeping every other host's entry. A version 1 file is rewritten as version 2 on the way through.