config

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Load

func Load(file string)

Load loads the config form the provided filepath

func LoadDefault

func LoadDefault()

LoadDefault loads the config from one of the default config locations

Types

type Config added in v0.2.0

type Config struct {
	URL     string                    `yaml:"instance"`
	Mytoken *mytokenlib.MytokenServer `yaml:"-"`

	DefaultGPGKey            string `yaml:"default_gpg_key"`
	DefaultProvider          string `yaml:"default_provider"`
	DefaultOIDCFlow          string `yaml:"default_oidc_flow"`
	DefaultTokenCapabilities struct {
		Stored   []string `yaml:"stored"`
		Returned []string `yaml:"returned"`
	} `yaml:"default_token_capabilities"`

	TokenNamePrefix string `yaml:"token_name_prefix"`

	Providers         model.Providers   `yaml:"providers"`
	TokensFilePath    string            `yaml:"tokens_file"`
	TokensFileContent *TokenFileContent `yaml:"-"`
	// contains filtered or unexported fields
}

func Get

func Get() *Config

Get returns the config

func (*Config) GetToken added in v0.2.0

func (c *Config) GetToken(
	issuer string, nameGet func() string, nameUpdater func(string),
	requiredCapability ...api.Capability,
) (
	string,
	error,
)

func (*Config) GetTokenEntry added in v0.4.0

func (c *Config) GetTokenEntry(
	issuer string, name string, nameUpdater func(string), requiredCapability ...api.
		Capability,
) (
	t TokenEntry,
	err error,
)

type Crypter added in v0.4.0

type Crypter interface {
	Encrypt(plain, secret string) (cipher string, err error)
	Decrypt(cipher, secret string) (plain string, err error)
}

type GPGAndPasswordCombinedCrypter added in v0.4.0

type GPGAndPasswordCombinedCrypter struct{}

func (GPGAndPasswordCombinedCrypter) Decrypt added in v0.4.0

func (GPGAndPasswordCombinedCrypter) Decrypt(cipher, gpgKey string) (plain string, err error)

func (GPGAndPasswordCombinedCrypter) Encrypt added in v0.4.0

func (GPGAndPasswordCombinedCrypter) Encrypt(plain, gpgKey string) (cipher string, err error)

type StoreToken added in v0.4.0

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

func NewEncryptedStoreToken added in v0.4.0

func NewEncryptedStoreToken(encrypted string) StoreToken

func NewPlainStoreToken added in v0.4.0

func NewPlainStoreToken(plain string) StoreToken

func (*StoreToken) Encrypted added in v0.4.0

func (t *StoreToken) Encrypted(secret string) (string, error)

func (StoreToken) MarshalJSON added in v0.4.0

func (t StoreToken) MarshalJSON() ([]byte, error)

func (*StoreToken) Plain added in v0.4.0

func (t *StoreToken) Plain(secret string) (string, error)

func (*StoreToken) UnmarshalJSON added in v0.4.0

func (t *StoreToken) UnmarshalJSON(data []byte) error

type TokenEntry

type TokenEntry struct {
	Name         string           `json:"name"`
	GPGKey       string           `json:"gpg_key,omitempty"`
	Token        StoreToken       `json:"token"`
	Capabilities api.Capabilities `json:"capabilities"`
}

func (TokenEntry) MarshalJSON added in v0.4.0

func (e TokenEntry) MarshalJSON() ([]byte, error)

type TokenFileContent added in v0.2.0

type TokenFileContent struct {
	TokenMapping tokenNameMapping `json:"mapping"`
	Tokens       tokenEntries     `json:"tokens"`
}

func LoadTokens

func LoadTokens() (*TokenFileContent, error)

func (*TokenFileContent) Add added in v0.2.0

func (f *TokenFileContent) Add(t TokenEntry, iss string)

func (TokenFileContent) Has added in v0.2.0

func (f TokenFileContent) Has(name, iss string) bool

func (*TokenFileContent) Remove added in v0.4.0

func (f *TokenFileContent) Remove(name, iss string)

func (*TokenFileContent) Save added in v0.2.0

func (f *TokenFileContent) Save() error

func (*TokenFileContent) Update added in v0.4.0

func (f *TokenFileContent) Update(name, iss string, token StoreToken)

Jump to

Keyboard shortcuts

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