credential

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package credential retrieves provider credentials without putting secrets in application configuration, sessions, logs, or events.

Index

Constants

View Source
const APIKeyEnv = "API_KEY"

APIKeyEnv is the provider-neutral API key variable used by the application.

Variables

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

ErrNotFound means no usable credential is available for a provider.

Functions

This section is empty.

Types

type Credential

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

Credential contains one provider API key. Its formatting is always redacted; callers must explicitly request the key at the provider boundary.

func (Credential) APIKey

func (c Credential) APIKey() string

APIKey returns the credential value for immediate provider construction.

func (Credential) Format

func (Credential) Format(state fmt.State, _ rune)

Format redacts the credential for every fmt verb, including %#v.

func (Credential) MarshalJSON

func (Credential) MarshalJSON() ([]byte, error)

MarshalJSON prevents reflective serialization from exposing internal credential representation.

type EnvironmentStore

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

EnvironmentStore reads provider API keys from an injected environment.

func NewEnvironmentStore

func NewEnvironmentStore(lookup LookupEnv) (*EnvironmentStore, error)

NewEnvironmentStore returns an environment-backed Store.

func (*EnvironmentStore) Get

func (s *EnvironmentStore) Get(ctx context.Context, provider ai.Provider) (Credential, error)

Get implements Store.

type LookupEnv

type LookupEnv func(string) (string, bool)

LookupEnv is the environment lookup contract used by EnvironmentStore.

type MissingError

type MissingError struct {
	Provider ai.Provider
	Variable string
}

MissingError identifies the provider and non-secret environment variable that was checked.

func (*MissingError) Error

func (e *MissingError) Error() string

Error implements error.

func (*MissingError) Unwrap

func (*MissingError) Unwrap() error

Unwrap makes MissingError match ErrNotFound.

type Store

type Store interface {
	Get(context.Context, ai.Provider) (Credential, error)
}

Store returns credentials at the point a provider model is constructed.

Jump to

Keyboard shortcuts

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