credentials

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package credentials keeps secret material outside SQLite, JSON, reports, events, and logs. Persistent application state carries only StoreRef values.

The operating-system APIs wrapped by go-keyring are synchronous and cannot be interrupted after a call begins. OSStore therefore checks context before and after every platform call; cancellation may wait for the platform call and a mutating call may have completed even when context cancellation is returned. Resolve a credential to one short-lived Lease at a run boundary, reuse its bytes for that run, then Close it. Do not fetch it repeatedly in a request hot path.

Index

Constants

This section is empty.

Variables

View Source
var ErrAlreadyExists = errors.New("credentials: already exists")

ErrAlreadyExists reports that Set would overwrite an existing credential.

View Source
var ErrClosed = errors.New("credentials: secret lease closed")

ErrClosed reports an attempt to read a released secret lease.

View Source
var ErrInvalid = errors.New("credentials: invalid input")

ErrInvalid reports a malformed credential reference or secret input.

View Source
var ErrNotFound = errors.New("credentials: not found")

ErrNotFound reports that a credential is absent.

View Source
var ErrUnavailable = errors.New("credentials: store unavailable")

ErrUnavailable reports that the backing credential service cannot be used.

Functions

This section is empty.

Types

type CleanupQueue

type CleanupQueue interface {
	Enqueue(context.Context, ...string) error
	List(context.Context) ([]string, error)
	Remove(context.Context, ...string) error
}

CleanupQueue is a durable non-secret registry of credential identifiers. Referenced IDs remain registered; an ID is removed only after its keyring entry is confirmed deleted once no authored Channel or immutable Plan binding references it.

type FileCleanupQueue

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

FileCleanupQueue stores only credential IDs. Secrets remain exclusively in the operating-system keyring.

func NewFileCleanupQueue

func NewFileCleanupQueue(path string) (*FileCleanupQueue, error)

func (*FileCleanupQueue) Enqueue

func (queue *FileCleanupQueue) Enqueue(ctx context.Context, ids ...string) error

func (*FileCleanupQueue) List

func (queue *FileCleanupQueue) List(ctx context.Context) ([]string, error)

func (*FileCleanupQueue) Remove

func (queue *FileCleanupQueue) Remove(ctx context.Context, ids ...string) error

type Lease

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

Lease gives short-lived access to a defensive copy of a secret. Close must be called as soon as the caller no longer needs the secret.

func NewTemporaryLease

func NewTemporaryLease(secret []byte) (*Lease, error)

NewTemporaryLease copies a transient credential without creating a keyring entry. The caller retains ownership of its input bytes and must close the returned lease when the operation ends.

func (*Lease) Bytes

func (lease *Lease) Bytes() ([]byte, error)

Bytes returns a defensive copy that the caller should zero after use.

func (*Lease) Close

func (lease *Lease) Close() error

Close zeroes the lease-owned bytes. It is safe to call more than once.

func (*Lease) GoString

func (*Lease) GoString() string

func (*Lease) MarshalJSON

func (*Lease) MarshalJSON() ([]byte, error)

MarshalJSON deliberately refuses to turn secret material into a transport value. Domain objects, reports, events, and logs must carry StoreRef only.

func (*Lease) String

func (*Lease) String() string

type MemoryCleanupQueue

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

MemoryCleanupQueue is the process-local implementation used by tests and embedders that do not persist application state.

func NewMemoryCleanupQueue

func NewMemoryCleanupQueue() *MemoryCleanupQueue

func (*MemoryCleanupQueue) Enqueue

func (queue *MemoryCleanupQueue) Enqueue(ctx context.Context, ids ...string) error

func (*MemoryCleanupQueue) List

func (queue *MemoryCleanupQueue) List(ctx context.Context) ([]string, error)

func (*MemoryCleanupQueue) Remove

func (queue *MemoryCleanupQueue) Remove(ctx context.Context, ids ...string) error

type MemoryStore

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

MemoryStore is a concurrent in-memory Store intended for tests and short-lived processes. It never serializes its contents.

func NewMemoryStore

func NewMemoryStore() *MemoryStore

func (*MemoryStore) Delete

func (store *MemoryStore) Delete(ctx context.Context, ref StoreRef) error

func (*MemoryStore) Get

func (store *MemoryStore) Get(ctx context.Context, ref StoreRef) (*Lease, error)

func (*MemoryStore) Replace

func (store *MemoryStore) Replace(ctx context.Context, ref StoreRef, secret []byte) error

func (*MemoryStore) Set

func (store *MemoryStore) Set(ctx context.Context, ref StoreRef, secret []byte) error

func (*MemoryStore) Test

func (store *MemoryStore) Test(ctx context.Context, ref StoreRef) error

type OSStore

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

OSStore persists credentials in the operating-system credential service. The gate preserves create-only Set and existing-only Replace semantics among callers in this process; operating-system keyrings do not offer a portable atomic create-if-absent primitive across processes.

func NewOSStore

func NewOSStore() *OSStore

func (*OSStore) Delete

func (store *OSStore) Delete(ctx context.Context, ref StoreRef) error

func (*OSStore) Get

func (store *OSStore) Get(ctx context.Context, ref StoreRef) (*Lease, error)

func (*OSStore) Replace

func (store *OSStore) Replace(ctx context.Context, ref StoreRef, secret []byte) error

func (*OSStore) Set

func (store *OSStore) Set(ctx context.Context, ref StoreRef, secret []byte) error

func (*OSStore) Test

func (store *OSStore) Test(ctx context.Context, ref StoreRef) error

type ScopedStore

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

ScopedStore transparently binds otherwise stable credential IDs to one storage root. Sharing a channels.json file or Run database therefore shares only non-secret metadata; each root must have its own keyring entry.

func NewScopedStore

func NewScopedStore(store Store, scope string) (*ScopedStore, error)

func (*ScopedStore) Delete

func (store *ScopedStore) Delete(ctx context.Context, ref StoreRef) error

func (*ScopedStore) Get

func (store *ScopedStore) Get(ctx context.Context, ref StoreRef) (*Lease, error)

func (*ScopedStore) Replace

func (store *ScopedStore) Replace(ctx context.Context, ref StoreRef, secret []byte) error

func (*ScopedStore) Set

func (store *ScopedStore) Set(ctx context.Context, ref StoreRef, secret []byte) error

func (*ScopedStore) Test

func (store *ScopedStore) Test(ctx context.Context, ref StoreRef) error

type Store

Store persists secrets outside application databases and serialized domain objects. Callers own every input byte slice and every returned Lease.

type StoreRef

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

StoreRef is a stable, non-secret identifier for an operating-system credential. Its fields are private so only canonical references can exist.

func NewStoreRef

func NewStoreRef(purpose domain.CredentialPurpose, id string) (StoreRef, error)

func ParseStoreRef

func ParseStoreRef(value string) (StoreRef, error)

func StoreRefFromCredential

func StoreRefFromCredential(ref domain.CredentialRef) (StoreRef, error)

func (StoreRef) ID

func (ref StoreRef) ID() string

func (StoreRef) Purpose

func (ref StoreRef) Purpose() domain.CredentialPurpose

func (StoreRef) Scope

func (ref StoreRef) Scope() string

Scope is empty for legacy references and contains the canonical authored catalog scope for references owned by a ScopedStore.

func (StoreRef) String

func (ref StoreRef) String() string

func (StoreRef) Value

func (ref StoreRef) Value() string

Jump to

Keyboard shortcuts

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