credhelpers

package
v1.40.0 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

A `pass` based credential helper. Passwords are stored as arguments to pass of the form: "$PASS_FOLDER/base64-url(serverURL)/username". We base64-url encode the serverURL, because under the hood pass uses files and folders, so /s will get translated into additional folders.

Index

Constants

View Source
const PASS_FOLDER = cst.CmdRoot

Variables

View Source
var CredsLabel = "Vault Token"

CredsLabel holds the way Docker credentials should be labeled as such in credentials stores that allow labeling. That label allows to filter out non-Docker credentials too at lookup/search in macOS keychain, Windows credentials manager and Linux libsecret. Default value is "Vault Token"

Functions

func Erase

func Erase(helper StoreHelper, reader io.Reader) error

Erase removes credentials from the store. The reader must contain the server URL to remove.

func Get

func Get(helper StoreHelper, reader io.Reader, writer io.Writer) error

Get retrieves the credentials for a given server url. The reader must contain the server URL to search. The writer is used to write the JSON serialization of the credentials.

func IsCredentialsMissingServerURL

func IsCredentialsMissingServerURL(err error) bool

IsCredentialsMissingServerURL returns true if the error was an errCredentialsMissingServerURL.

func IsCredentialsMissingServerURLMessage

func IsCredentialsMissingServerURLMessage(err string) bool

IsCredentialsMissingServerURLMessage checks for an errCredentialsMissingServerURL in the error message.

func IsCredentialsMissingUsername

func IsCredentialsMissingUsername(err error) bool

IsCredentialsMissingUsername returns true if the error was an errCredentialsMissingUsername.

func IsCredentialsMissingUsernameMessage

func IsCredentialsMissingUsernameMessage(err string) bool

IsCredentialsMissingUsernameMessage checks for an errCredentialsMissingUsername in the error message.

func IsErrCredentialsNotFound

func IsErrCredentialsNotFound(err error) bool

IsErrCredentialsNotFound returns true if the error was caused by not having a set of credentials in a store.

func IsErrCredentialsNotFoundMessage

func IsErrCredentialsNotFoundMessage(err string) bool

IsErrCredentialsNotFoundMessage returns true if the error was caused by not having a set of credentials in a store.

This function helps to check messages returned by an external program via its standard output.

func List

func List(helper StoreHelper, writer io.Writer) error

List returns all the serverURLs of keys in the OS store as a list of strings

func NewErrCredentialsMissingServerURL

func NewErrCredentialsMissingServerURL() error

NewErrCredentialsMissingServerURL creates a new error for errCredentialsMissingServerURL.

func NewErrCredentialsMissingUsername

func NewErrCredentialsMissingUsername() error

NewErrCredentialsMissingUsername creates a new error for errCredentialsMissingUsername.

func NewErrCredentialsNotFound

func NewErrCredentialsNotFound() error

NewErrCredentialsNotFound creates a new error for when the credentials are not in the store.

func SetCredsLabel

func SetCredsLabel(label string)

SetCredsLabel is a simple setter for CredsLabel

func Store

func Store(helper StoreHelper, reader io.Reader) error

Store uses a helper and an input reader to save credentials. The reader must contain the JSON serialization of a Credentials struct.

Types

type Credentials

type Credentials struct {
	ServerURL string
	Username  string
	Secret    string
}

Credentials holds the information shared between docker and the credentials store.

type Pass

type Pass struct{}

Pass handles secrets using Linux secret-service as a store.

func (Pass) Add

func (h Pass) Add(creds *Credentials) error

Add adds new credentials to the keychain.

func (Pass) CheckInitialized

func (p Pass) CheckInitialized() bool

CheckInitialized checks whether the password helper can be used. It internally caches and so may be safely called multiple times with no impact on performance, though the first call may take longer.

func (Pass) Delete

func (h Pass) Delete(serverURL string) error

Delete removes credentials from the store.

func (Pass) Get

func (h Pass) Get(url string) (string, string, error)

Get returns the username and secret to use for a given registry server URL.

func (Pass) GetName

func (h Pass) GetName() string

GetName gets friendly name of service

func (Pass) List

func (h Pass) List(prefix string) (map[string]string, error)

List returns the stored URLs and corresponding usernames for a given credentials label

type StoreHelper

type StoreHelper interface {
	// Add appends credentials to the store.
	Add(*Credentials) error
	// Delete removes credentials from the store.
	Delete(serverURL string) error
	// Get retrieves credentials from the store.
	// It returns username and secret as strings.
	Get(serverURL string) (string, string, error)
	// List returns the stored serverURLs and their associated usernames.
	List(prefix string) (map[string]string, error)
	// GetName returns the friendly name of helper.
	GetName() string
}

StoreHelper is the interface a credentials store helper must implement.

Jump to

Keyboard shortcuts

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