creds

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package creds reads credentials.toml and materializes the secrets it points at.

Index

Constants

View Source
const CommandTimeout = 2 * time.Minute

CommandTimeout bounds a secret-fetching command. Generous, because a vault may wait on a hardware key tap.

View Source
const RequiredMode os.FileMode = 0o600

RequiredMode is the only permission blip will read a credentials file at.

Variables

View Source
var ErrNoFile = errors.New("no credentials file")

ErrNoFile means the credentials file does not exist.

Functions

This section is empty.

Types

type Kind

type Kind string

Kind is an auth mechanism.

const (
	KindNone     Kind = "none"
	KindBearer   Kind = "bearer"
	KindHeader   Kind = "header"
	KindBasic    Kind = "basic"
	KindOAuth2CC Kind = "oauth2_cc"
)

type Profile

type Profile struct {
	Type string `toml:"type"`

	// Hosts pins this credential to the hosts it may be sent to. .blip.toml is
	// committed and can come from anywhere, so without this a cloned repo picks
	// both the destination and which of your secrets travels to it.
	Hosts []string `toml:"hosts"`

	Token        string `toml:"token"`
	TokenCommand string `toml:"token_command"`

	Header       string `toml:"header"`
	Value        string `toml:"value"`
	ValueCommand string `toml:"value_command"`

	Username        string `toml:"username"`
	Password        string `toml:"password"`
	PasswordCommand string `toml:"password_command"`

	TokenURL            string `toml:"token_url"`
	ClientID            string `toml:"client_id"`
	ClientSecret        string `toml:"client_secret"`
	ClientSecretCommand string `toml:"client_secret_command"`
	Scope               string `toml:"scope"`
	Audience            string `toml:"audience"`
}

Profile is one named block in credentials.toml.

type Resolved

type Resolved struct {
	Name     string
	Kind     Kind
	Hosts    []string
	Token    string
	Header   string
	Value    string
	Username string
	Password string

	TokenURL     string
	ClientID     string
	ClientSecret string
	Scope        string
	Audience     string
}

Resolved is a profile with every secret materialized. It must never be printed.

func (*Resolved) SecretValues

func (r *Resolved) SecretValues() []string

SecretValues lists everything in this profile that must never reach output.

type Resolver

type Resolver struct {
	Run Runner
}

Resolver materializes the secrets a profile points at.

func NewResolver

func NewResolver(stdin *os.File, stderr *os.File) *Resolver

NewResolver returns a resolver that runs commands through the shell.

type Runner

type Runner func(ctx context.Context, command string) (string, error)

Runner executes a secret-fetching command and returns its stdout.

type Store

type Store struct {
	Path     string
	Profiles map[string]Profile
}

Store is a parsed credentials file.

func Load

func Load() (*Store, error)

Load reads the credentials file at the default location.

func LoadFile

func LoadFile(path string) (*Store, error)

LoadFile reads a credentials file, refusing anything more permissive than 0600.

func (*Store) Names

func (s *Store) Names() []string

Names lists the profiles in a stable order.

func (*Store) Resolve

func (s *Store) Resolve(ctx context.Context, name string, r *Resolver) (*Resolved, error)

Resolve materializes every secret in the named profile.

Jump to

Keyboard shortcuts

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