credentials

package
v1.0.21 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: MIT Imports: 8 Imported by: 1

Documentation

Overview

Package credentials describes credentials.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAgentSocketFromConfig added in v1.0.8

func GetAgentSocketFromConfig(host string) (string, error)

GetAgentSocketFromConfig computes SSH authentication agent socket path using default ssh config's IdentityAgent and ForwardAgent keywords. IdentityAgent value supports tilde syntax, but it doesn't support %d, %h, %l and %r.

func GetDefaultAgentSocket added in v1.0.8

func GetDefaultAgentSocket() string

GetDefaultAgentSocket returns default ssh authentication agent socket (read from SSH_AUTH_SOCK env)

func GetLogin

func GetLogin() string

GetLogin tries to get sudo user from env, falling back to current user

func GetPrivateKeysFromConfig added in v1.0.8

func GetPrivateKeysFromConfig(host string) ([][]byte, error)

GetPrivateKeysFromConfig tries to extract PrivateKeys from default config's IdentityFiles specifed for provided host. IdentityFile value supports tilde syntax, but it doesn't support %d, %u, %l, %h and %r.

func GetUsernameFromConfig added in v1.0.8

func GetUsernameFromConfig(host string) string

GetUsernameFromConfig extracts User keyword value for given host from default ssh config.

Types

type Credentials

type Credentials interface {
	GetUsername() (string, error)
	GetPasswords() []Secret
	GetPrivateKeys() [][]byte
	GetPassphrase() Secret
	GetAgentSocket() string
}

type CredentialsOption

type CredentialsOption func(*SimpleCredentials)

func WithLogger

func WithLogger(logger *zap.Logger) CredentialsOption

func WithPassphrase

func WithPassphrase(passphrase Secret) CredentialsOption

func WithPassword

func WithPassword(password Secret) CredentialsOption

func WithPasswords

func WithPasswords(password []Secret) CredentialsOption

func WithPrivateKey

func WithPrivateKey(key []byte) CredentialsOption

func WithPrivateKeys added in v1.0.8

func WithPrivateKeys(key [][]byte) CredentialsOption

func WithSSHAgentSocket added in v1.0.8

func WithSSHAgentSocket(agentSocket string) CredentialsOption

func WithUsername

func WithUsername(username string) CredentialsOption

type Secret

type Secret string

func (Secret) MarshalText

func (Secret) MarshalText() ([]byte, error)

func (Secret) String

func (Secret) String() string

func (Secret) Value

func (m Secret) Value() string

type SimpleCredentials

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

func NewSimpleCredentials

func NewSimpleCredentials(opts ...CredentialsOption) *SimpleCredentials

func (SimpleCredentials) GetAgentSocket added in v1.0.8

func (m SimpleCredentials) GetAgentSocket() string

func (SimpleCredentials) GetPassphrase

func (m SimpleCredentials) GetPassphrase() Secret

func (SimpleCredentials) GetPasswords

func (m SimpleCredentials) GetPasswords() []Secret

func (SimpleCredentials) GetPrivateKeys added in v1.0.8

func (m SimpleCredentials) GetPrivateKeys() [][]byte

func (SimpleCredentials) GetUsername

func (m SimpleCredentials) GetUsername() (string, error)

Jump to

Keyboard shortcuts

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