auth

package
v0.19.24 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// NetrcUsernameField is the value that holds the username in the netrc format
	NetrcUsernameField string = "login"

	// NetrcPasswordField is the value that holds the passwod in the netrc format
	NetrcPasswordField string = "password"

	// NetrcDefaultFilename is the default name of the netrc configuration file.
	NetrcDefaultFilename string = ".netrc"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	User     *user.User
	Filename string
}

Config represents a configuration structure passed to the Netrc object in order to initialize it

func NewConfig

func NewConfig() (*Config, error)

NewConfig returns a new configuration structure for the netrc authenticator.

type Interface

type Interface interface {
	// GetAuth retrieves the authentication credentials for a given host, or
	// throws an error
	GetUsernamePassword(host string) (string, string, error)
}

Interface is a generic authentication interface

type NetrcAuth

type NetrcAuth struct {
	// Config is the reference to the config struct
	Config *Config

	// Netrc is the parsed netrc file
	Netrc *netrc.Netrc
}

NetrcAuth reresents the implementation of the netrc authentication manager interface

func NewNetrc

func NewNetrc(cfg *Config) (*NetrcAuth, error)

NewNetrc creates a new netrc auth manager, or returns an error

func (*NetrcAuth) GetAuth

func (a *NetrcAuth) GetAuth(host string) (string, string, error)

GetAuth retrieves authentication credentials from the parsed netrc file, given that the host exists

func (*NetrcAuth) ParseNetrc

func (a *NetrcAuth) ParseNetrc() (*netrc.Netrc, error)

ParseNetrc parses the netrc that is given to the auth manager

Jump to

Keyboard shortcuts

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