creds

package
v0.6.76 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: AGPL-3.0, Apache-2.0, MIT Imports: 25 Imported by: 0

Documentation

Overview

Package creds manages the credentials that must live in the sandbox (sections 4.9 and 4.11): cloud OIDC token files with SDK configuration, and the Codex subscription bundle on tmpfs with compare-and-swap write-back. Everything else (SCM, AI proxy, console, Claude OAuth) is injected at egress and never enters the box.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dial

func Dial(rawURL, caBundle string) (devboxv1.SandboxCredentialsClient, *grpc.ClientConn, error)

Dial connects to the gateway's SandboxCredentials service through egress. https URLs use TLS with the sandbox's trust bundle (egress intercepts and re-signs); http URLs are plaintext.

Types

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager owns sandbox credentials.

func New

func New(opts Options) *Manager

New returns a Manager.

func (*Manager) CodexAuthDir

func (m *Manager) CodexAuthDir() string

CodexAuthDir is the tmpfs CODEX_HOME holding auth.json.

func (*Manager) CodexAuthFile

func (m *Manager) CodexAuthFile() string

CodexAuthFile is the tmpfs auth.json.

func (*Manager) CodexInstalled

func (m *Manager) CodexInstalled() bool

CodexInstalled reports whether a Codex credential is installed.

func (*Manager) DetectInBoxLogins

func (m *Manager) DetectInBoxLogins() []string

DetectInBoxLogins reports vendor logins made inside the box (they land on the workspace volume and in snapshots).

func (*Manager) Env

func (m *Manager) Env() []string

Env returns the default identities' environment (for harness and terminal processes).

func (*Manager) FetchCodex

func (m *Manager) FetchCodex(ctx context.Context) error

FetchCodex fetches the owner's Codex credential and installs it (harness start for subscription billing).

func (*Manager) InstallCodex

func (m *Manager) InstallCodex(ctx context.Context, cred *devboxv1.InstanceCredential) (bool, error)

InstallCodex writes a Codex credential to tmpfs. Bundles older than the installed version are ignored. It reports whether the credential was applied.

func (*Manager) PushCredential

func (m *Manager) PushCredential(ctx context.Context, cred *devboxv1.InstanceCredential) (bool, error)

PushCredential applies a credential pushed by the gateway (refreshed Codex bundles, OIDC tokens).

func (*Manager) RefreshOIDC

func (m *Manager) RefreshOIDC(ctx context.Context) (time.Time, error)

RefreshOIDC fetches current tokens for every identity and rewrites their files. It returns when the next refresh is due.

func (*Manager) Restore

func (m *Manager) Restore(ctx context.Context, codex bool) error

Restore refetches credentials after a resume or restore (Scrub removed them).

func (*Manager) RunOIDC

func (m *Manager) RunOIDC(ctx context.Context)

RunOIDC keeps token files fresh until ctx ends.

func (*Manager) Scrub

func (m *Manager) Scrub() []string

Scrub deletes every credential that must not be captured in a snapshot: tmpfs subscription credentials, OIDC token files and SDK caches. It returns the removed paths. Config files (profiles, external_account JSON) stay: they hold no secrets.

func (*Manager) SetIdentities

func (m *Manager) SetIdentities(ids []*devboxv1.CloudIdentity) error

SetIdentities records the box's cloud identities and writes their SDK configuration.

func (*Manager) TokenPath

func (m *Manager) TokenPath(name string) string

TokenPath is an identity's token file.

func (*Manager) WatchCodex

func (m *Manager) WatchCodex(ctx context.Context)

WatchCodex watches the tmpfs auth.json for Codex's refreshes and renews the refresh lease before it expires.

func (*Manager) WriteSDKConfig

func (m *Manager) WriteSDKConfig() error

WriteSDKConfig writes per-identity SDK config and the env file shells and harnesses source:

  • AWS: ~/.aws/config profiles (web_identity_token_file), plus AWS_* env for the default;
  • GCP: <identity>/gcp-credentials.json external_account configs, GOOGLE_APPLICATION_CREDENTIALS for the default;
  • Azure: <identity>/azure.env, plus AZURE_* env for the default.

type Options

type Options struct {
	Home string
	// IdentityDir holds OIDC token files and SDK config (/run/plural/identity).
	IdentityDir string
	// AgentAuthDir is the subscription-credential tmpfs (/run/plural/agent-auth).
	AgentAuthDir string
	// Client returns the SandboxCredentials client (nil while Initialize hasn't provided endpoints).
	Client     func() devboxv1.SandboxCredentialsClient
	InstanceID func() string
	Clock      clock.Clock
	Log        *slog.Logger
	// Condition reports a daemon condition.
	Condition func(typ, severity, msg string, active bool)
	// CodexLogin runs `codex login --with-access-token` (overridable in tests).
	CodexLogin func(ctx context.Context, codexHome, token string) error
}

Options configure a Manager.

Jump to

Keyboard shortcuts

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