auth

package
v0.0.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 3, 2026 License: MIT Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package auth persists the credential bundle from /api/v1/runtimes/pair: server URL, runtime row id (= device_id), and the long-lived runner_credential. Stored as JSON per-profile at ~/.oac/daemon/<profile>/auth.json (0o600), written via atomic rename so a half-flushed pair never leaves the daemon paired with garbage state.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotPaired = errors.New("auth: not paired — use `oac-daemon connect --url ... --token ...`")

ErrNotPaired is returned by Load when no auth.json exists for the requested profile.

Functions

func Delete

func Delete(profile string) error

Delete removes the auth.json for a profile. Idempotent — missing file is not an error.

func Save

func Save(profile string, p Profile) error

Save writes p atomically to the profile's auth.json (0o600 even if the previous file was world-readable).

Types

type Profile

type Profile struct {
	// ServerURL is the absolute base URL the daemon dials (no
	// trailing slash). The daemon joins this with paths like
	// /agent-daemon/bootstrap.
	ServerURL string `json:"server_url"`

	// RuntimeID is the runtimes row id minted at pair time. The
	// gateway uses it verbatim as device_id on WS upgrade.
	RuntimeID string `json:"runtime_id"`

	// RunnerCredential is the bearer presented on every
	// /agent-daemon/* call. Stored plaintext in a 0o600 file; the
	// server holds only the hash, so this is the only proof of
	// identity and MUST NOT be checked into VCS.
	RunnerCredential string `json:"runner_credential"`

	DeviceName string `json:"device_name,omitempty"`

	Hostname string `json:"hostname,omitempty"`

	// PairedAt is when the credential was minted. `omitzero` because
	// `omitempty` doesn't elide zero structs like time.Time.
	PairedAt time.Time `json:"paired_at,omitzero"`

	// RunnerPublicKey is the base64 X25519 public half generated at
	// pair time. Server stores the matching value in
	// runtimes.config.runner_public_key for SealAnonymous addressed
	// to this daemon.
	RunnerPublicKey string `json:"runner_public_key,omitempty"`

	// RunnerPrivateKey is the base64 X25519 private half — used by
	// runtimecrypto.OpenSeal to decrypt incoming sealed payloads.
	// MUST NEVER appear in logs or leave the box.
	RunnerPrivateKey string `json:"runner_private_key,omitempty"`
}

Profile is the on-disk representation of one paired credential.

func Load

func Load(profile string) (Profile, error)

Load reads the profile's auth.json. Returns ErrNotPaired wrapping fs.ErrNotExist when the file is missing.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL