credentials

package
v0.1.29 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package credentials adapts cli-common/credstore to cr's command surface.

Index

Constants

View Source
const (
	// ServiceName is the credential-ref service segment owned by cr.
	ServiceName = "codereview"

	// GitTokenKey stores the Git host access token for PAT auth.
	GitTokenKey = "git_token"
	// LLMAPIKeyKey stores the key name for direct LLM provider adapters.
	// #nosec G101 -- this is a keyring item name, not a secret value.
	LLMAPIKeyKey = "llm_api_key"
)

Variables

View Source
var (
	// ErrWrongService means a credential ref points at another CLI's keyring namespace.
	ErrWrongService = errors.New("credentials: credential ref uses wrong service")
	// ErrInvalidBackendSelection means a CLI/config backend selector was malformed.
	ErrInvalidBackendSelection = errors.New("credentials: invalid backend selection")
)

Functions

func AllowedKeys

func AllowedKeys() []string

AllowedKeys is cr's keyring write allowlist.

func BackendEnvVar

func BackendEnvVar() string

BackendEnvVar returns cr's backend selector environment variable name.

func BackendMetadata

func BackendMetadata(flagValue string, flagSet bool, cfg config.File) (credstore.Backend, credstore.Source, error)

BackendMetadata reports the selected backend/source without opening the store.

func FormatRef

func FormatRef(profile string) (string, error)

FormatRef returns the canonical ref for a cr profile segment.

func KeyForPurpose

func KeyForPurpose(ref config.CredentialRef) (string, error)

KeyForPurpose returns the keyring key expected for a config credential ref.

func OpenStore

func OpenStore(flagValue string, flagSet bool, cfg config.File) (*credstore.Store, error)

OpenStore opens the service-scoped keyring store.

func StoreOptions

func StoreOptions(flagValue string, flagSet bool, cfg config.File) (credstore.Options, error)

StoreOptions validates backend selectors and returns credstore options.

func TrimSecretIngress

func TrimSecretIngress(value string) string

TrimSecretIngress removes the terminal newline produced by echo/heredocs without treating other whitespace as disposable.

func ValidateAllowedKey

func ValidateAllowedKey(key string) error

ValidateAllowedKey fails when key is not in cr's write allowlist.

Types

type Ref

type Ref struct {
	Service string
	Profile string
	Full    string
}

Ref is a parsed cr credential ref.

func ParseRef

func ParseRef(ref string) (Ref, error)

ParseRef validates ref with the shared grammar and cr's service segment.

Jump to

Keyboard shortcuts

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