git-bug: github.com/MichaelMure/git-bug/bridge/core/auth Index | Files

package auth

import "github.com/MichaelMure/git-bug/bridge/core/auth"

Index

Package Files

credential.go credential_base.go login.go login_password.go options.go token.go

Constants

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

Variables

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

func IdExist Uses

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

IdExist return whether a credential id exist or not

func NewErrMultipleMatchCredential Uses

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

func PrefixExist Uses

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

PrefixExist return whether a credential id prefix exist or not

func Remove Uses

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

Remove removes a credential from the global git config

func Store Uses

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

Store stores a credential in the global git config

type ById Uses

type ById []Credential

func (ById) Len Uses

func (b ById) Len() int

func (ById) Less Uses

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

func (ById) Swap Uses

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

type Credential Uses

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 Uses

func List(repo repository.RepoConfig, opts ...Option) ([]Credential, error)

List load all existing credentials

func LoadWithId Uses

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

Load loads a credential from the repo config

func LoadWithPrefix Uses

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

LoadWithPrefix load a credential from the repo config with a prefix

type CredentialKind Uses

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

type Login Uses

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

func NewLogin Uses

func NewLogin(target, login string) *Login

func NewLoginFromConfig Uses

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

func (Login) CreateTime Uses

func (cb Login) CreateTime() time.Time

func (Login) GetMetadata Uses

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

func (*Login) ID Uses

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

func (*Login) Kind Uses

func (lp *Login) Kind() CredentialKind

func (Login) Metadata Uses

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

func (Login) Salt Uses

func (cb Login) Salt() []byte

func (Login) SetMetadata Uses

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

func (Login) Target Uses

func (cb Login) Target() string

func (*Login) Validate Uses

func (lp *Login) Validate() error

type LoginPassword Uses

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

func NewLoginPassword Uses

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

func NewLoginPasswordFromConfig Uses

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

func (LoginPassword) CreateTime Uses

func (cb LoginPassword) CreateTime() time.Time

func (LoginPassword) GetMetadata Uses

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

func (*LoginPassword) ID Uses

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

func (*LoginPassword) Kind Uses

func (lp *LoginPassword) Kind() CredentialKind

func (LoginPassword) Metadata Uses

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

func (LoginPassword) Salt Uses

func (cb LoginPassword) Salt() []byte

func (LoginPassword) SetMetadata Uses

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

func (LoginPassword) Target Uses

func (cb LoginPassword) Target() string

func (*LoginPassword) Validate Uses

func (lp *LoginPassword) Validate() error

type Option Uses

type Option func(opts *options)

func WithKind Uses

func WithKind(kind CredentialKind) Option

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

func WithMeta Uses

func WithMeta(key string, val string) Option

func WithTarget Uses

func WithTarget(target string) Option

type Token Uses

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

Token holds an API access token data

func NewToken Uses

func NewToken(target, value string) *Token

NewToken instantiate a new token

func NewTokenFromConfig Uses

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

func (Token) CreateTime Uses

func (cb Token) CreateTime() time.Time

func (Token) GetMetadata Uses

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

func (*Token) ID Uses

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

func (*Token) Kind Uses

func (t *Token) Kind() CredentialKind

func (Token) Metadata Uses

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

func (Token) Salt Uses

func (cb Token) Salt() []byte

func (Token) SetMetadata Uses

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

func (Token) Target Uses

func (cb Token) Target() string

func (*Token) Validate Uses

func (t *Token) Validate() error

Validate ensure token important fields are valid

Package auth imports 11 packages (graph) and is imported by 5 packages. Updated 2020-02-24. Refresh now. Tools for package owners.