passwordpersist

package
v0.9.6 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package passwordpersist manages password persistence.

Index

Constants

This section is empty.

Variables

View Source
var ErrPasswordNotFound = errors.Errorf("password not found")

ErrPasswordNotFound is returned when a password cannot be found in a persistent storage.

View Source
var ErrUnsupported = errors.Errorf("password storage not supported")

ErrUnsupported is returned when a password storage is not supported.

Functions

func OnSuccess

func OnSuccess(ctx context.Context, err error, s Strategy, configFile, password string) error

OnSuccess is a helper that persists the given (configFile,password) if the provided err is nil and deletes any persisted password otherwise.

Types

type Multiple

type Multiple []Strategy

Multiple is a Strategy that tries several underlying persistence strategies.

func (Multiple) DeletePassword

func (m Multiple) DeletePassword(ctx context.Context, configFile string) error

DeletePassword deletes the password from all persistent storages.

func (Multiple) GetPassword

func (m Multiple) GetPassword(ctx context.Context, configFile string) (string, error)

GetPassword retrieves the password form the first password storage that has it.

func (Multiple) PersistPassword

func (m Multiple) PersistPassword(ctx context.Context, configFile, password string) error

PersistPassword persists the provided password using the first method that succeeds.

type Strategy

type Strategy interface {
	// GetPassword gets persisted password, returns ErrNotFound or fatal errors.
	GetPassword(ctx context.Context, configFile string) (string, error)

	// PersistPassword persists a password, returns ErrUnsupported or fatal errors.
	PersistPassword(ctx context.Context, configFile, password string) error

	// DeletePassword deletes any persisted password, returns fatal errors.
	DeletePassword(ctx context.Context, configFile string) error
}

Strategy encapsulates persisting and fetching passwords.

var File Strategy = filePasswordStorage{}

File is a Strategy that persists the base64-encoded password in a file next to repository config file.

var Keyring Strategy = keyringStrategy{}

Keyring is a Strategy that persists the password in OS-specific keyring.

var None Strategy = noneStrategy{}

None is a strategy that does not persist the password at all.

Jump to

Keyboard shortcuts

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