sink

package
v0.2.64 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package sink defines the managed writable secret sink contract. The host coordinator uses it to capture provider-returned secrets durably without ever exposing plaintext to provider code, and to recover captured secrets on the host side for its own use. A managed cloud backend implements the same contract behind an adapter; the in-process Memory implementation here is the conformance reference that host and adapter behavior are tested against.

The contract has four operations:

  • Prepare returns an opaque capture target for one scoped secret slot.
  • PutDurable makes a captured value durable before it reports success.
  • Lookup recovers a durable value for authorized host use only.
  • AbortUnused removes a reservation only while it is still unfilled.

A value that PutDurable has made durable is never rolled back implicitly: a later action failing does not undo the capture, and AbortUnused refuses to touch a filled reservation. Removing a durable secret is the explicit, separately audited Revoke lifecycle.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Address

type Address struct {
	Consumer    string
	Environment string
	Binding     string
	Provider    string
	Purpose     providerv0.CredentialPurpose
	Name        string
}

Address scopes one secret slot by consumer, environment, binding, provider, and credential purpose. Name distinguishes multiple slots that otherwise share the same scope (for example two webhook secrets on one binding).

type AuditEvent

type AuditEvent struct {
	Seq         uint64
	Op          AuditOp
	Consumer    string
	Environment string
	Binding     string
	Provider    string
	Purpose     providerv0.CredentialPurpose
	Name        string
	Reference   string
	Version     uint64
	Fingerprint string
}

AuditEvent records one sink operation. It carries scope, the opaque reference, the version, and a non-reversible fingerprint, but never a secret value.

type AuditOp

type AuditOp string

AuditOp names a sink operation in the value-free audit log.

const (
	OpPrepare     AuditOp = "prepare"
	OpPutDurable  AuditOp = "put_durable"
	OpLookup      AuditOp = "lookup"
	OpAbortUnused AuditOp = "abort_unused"
	OpRevoke      AuditOp = "revoke"
)

type Memory

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

Memory is the in-process reference implementation of Sink. It enforces every contract property so host and backend adapters can be tested against it.

func NewMemory

func NewMemory() (*Memory, error)

NewMemory returns an empty reference sink with a fresh fingerprint key.

func (*Memory) AbortUnused

func (m *Memory) AbortUnused(target string) error

func (*Memory) Audit

func (m *Memory) Audit() []AuditEvent

Audit returns a copy of the value-free audit log in operation order.

func (*Memory) Lookup

func (m *Memory) Lookup(ref *providerv0.OpaqueReference) ([]byte, error)

func (*Memory) Prepare

func (m *Memory) Prepare(addr Address, oneTime bool) (Reservation, error)

func (*Memory) PutDurable

func (m *Memory) PutDurable(target string, value []byte) (*providerv0.OpaqueReference, error)

func (*Memory) Revoke

func (m *Memory) Revoke(ref *providerv0.OpaqueReference) error

Revoke removes a durable secret. It is the only path that deletes durable material and is audited distinctly from an unused-reservation abort.

type Reservation

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

Reservation is an opaque capture target bound to one Address. Provider code never sees it; the host hands PutDurable the Target once a value is captured.

func (Reservation) Address

func (r Reservation) Address() Address

Address returns the scope the reservation was prepared for.

func (Reservation) OneTime

func (r Reservation) OneTime() bool

OneTime reports whether the reserved slot holds a one-time secret that Lookup consumes on first authorized recovery.

func (Reservation) Target

func (r Reservation) Target() string

Target is the opaque capture target. It reveals nothing about the value and is safe to carry through host coordination.

type Sink

type Sink interface {
	// Prepare returns a stable opaque capture target for addr. Preparing the
	// same address again returns the same target so retried preparation does
	// not fork a second reservation.
	Prepare(addr Address, oneTime bool) (Reservation, error)
	// PutDurable makes value durable for the reservation identified by target
	// and returns an opaque reference to it. Re-putting the value already stored
	// for the target is idempotent and returns the same reference; putting a
	// different value rotates to a new version.
	PutDurable(target string, value []byte) (*providerv0.OpaqueReference, error)
	// Lookup recovers the durable value for host use. It never returns a value
	// to provider code. A one-time secret is consumed on the first Lookup.
	Lookup(ref *providerv0.OpaqueReference) ([]byte, error)
	// AbortUnused removes a still-unfilled reservation. It refuses to remove a
	// reservation whose value has already been made durable.
	AbortUnused(target string) error
}

Sink is the managed writable secret sink contract.

Jump to

Keyboard shortcuts

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