auth

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2022 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MetaKeyLogin   = "login"
	MetaKeyBaseURL = "base-url"
)

Variables

View Source
var ErrCredentialNotExist = errors.New("credential doesn't exist")

Functions

func IdExist

func IdExist(repo repository.RepoKeyring, id entity.Id) bool

IdExist return whether a credential id exist or not

func NewErrMultipleMatchCredential

func NewErrMultipleMatchCredential(matching []entity.Id) *entity.ErrMultipleMatch

func PrefixExist

func PrefixExist(repo repository.RepoKeyring, prefix string) bool

PrefixExist return whether a credential id prefix exist or not

func Remove

func Remove(repo repository.RepoKeyring, id entity.Id) error

Remove removes a credential from the global git config

func Store

func Store(repo repository.RepoKeyring, cred Credential) error

Store stores a credential in the global git config

Types

type ById

type ById []Credential

func (ById) Len

func (b ById) Len() int

func (ById) Less

func (b ById) Less(i, j int) bool

func (ById) Swap

func (b ById) Swap(i, j int)

type Credential

type Credential interface {
	ID() entity.Id
	Kind() CredentialKind
	Target() string
	CreateTime() time.Time
	Salt() []byte
	Validate() error

	Metadata() map[string]string
	GetMetadata(key string) (string, bool)
	SetMetadata(key string, value string)
	// contains filtered or unexported methods
}

func List

func List(repo repository.RepoKeyring, opts ...ListOption) ([]Credential, error)

List load all existing credentials

func LoadWithId

func LoadWithId(repo repository.RepoKeyring, id entity.Id) (Credential, error)

Load loads a credential from the repo config

func LoadWithPrefix

func LoadWithPrefix(repo repository.RepoKeyring, prefix string) (Credential, error)

LoadWithPrefix load a credential from the repo config with a prefix

type CredentialKind

type CredentialKind string
const (
	KindToken         CredentialKind = "token"
	KindLogin         CredentialKind = "login"
	KindLoginPassword CredentialKind = "login-password"
)

type ListOption added in v0.8.0

type ListOption func(opts *listOptions)

func WithKind

func WithKind(kind CredentialKind) ListOption

WithKind match credentials with the given kind. Can be specified multiple times.

func WithMeta

func WithMeta(key string, val string) ListOption

func WithTarget

func WithTarget(target string) ListOption

type Login

type Login struct {
	Login string
	// contains filtered or unexported fields
}

func NewLogin

func NewLogin(target, login string) *Login

func NewLoginFromConfig

func NewLoginFromConfig(conf map[string]string) (*Login, error)

func (Login) CreateTime

func (cb Login) CreateTime() time.Time

func (Login) GetMetadata

func (cb Login) GetMetadata(key string) (string, bool)

func (*Login) ID

func (lp *Login) ID() entity.Id

func (*Login) Kind

func (lp *Login) Kind() CredentialKind

func (Login) Metadata

func (cb Login) Metadata() map[string]string

func (Login) Salt

func (cb Login) Salt() []byte

func (Login) SetMetadata

func (cb Login) SetMetadata(key string, value string)

func (Login) Target

func (cb Login) Target() string

func (*Login) Validate

func (lp *Login) Validate() error

type LoginPassword

type LoginPassword struct {
	Login    string
	Password string
	// contains filtered or unexported fields
}

func NewLoginPassword

func NewLoginPassword(target, login, password string) *LoginPassword

func NewLoginPasswordFromConfig

func NewLoginPasswordFromConfig(conf map[string]string) (*LoginPassword, error)

func (LoginPassword) CreateTime

func (cb LoginPassword) CreateTime() time.Time

func (LoginPassword) GetMetadata

func (cb LoginPassword) GetMetadata(key string) (string, bool)

func (*LoginPassword) ID

func (lp *LoginPassword) ID() entity.Id

func (*LoginPassword) Kind

func (lp *LoginPassword) Kind() CredentialKind

func (LoginPassword) Metadata

func (cb LoginPassword) Metadata() map[string]string

func (LoginPassword) Salt

func (cb LoginPassword) Salt() []byte

func (LoginPassword) SetMetadata

func (cb LoginPassword) SetMetadata(key string, value string)

func (LoginPassword) Target

func (cb LoginPassword) Target() string

func (*LoginPassword) Validate

func (lp *LoginPassword) Validate() error

type Token

type Token struct {
	Value string
	// contains filtered or unexported fields
}

Token holds an API access token data

func NewToken

func NewToken(target, value string) *Token

NewToken instantiate a new token

func NewTokenFromConfig

func NewTokenFromConfig(conf map[string]string) (*Token, error)

func (Token) CreateTime

func (cb Token) CreateTime() time.Time

func (Token) GetMetadata

func (cb Token) GetMetadata(key string) (string, bool)

func (*Token) ID

func (t *Token) ID() entity.Id

func (*Token) Kind

func (t *Token) Kind() CredentialKind

func (Token) Metadata

func (cb Token) Metadata() map[string]string

func (Token) Salt

func (cb Token) Salt() []byte

func (Token) SetMetadata

func (cb Token) SetMetadata(key string, value string)

func (Token) Target

func (cb Token) Target() string

func (*Token) Validate

func (t *Token) Validate() error

Validate ensure token important fields are valid

Jump to

Keyboard shortcuts

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