config

package
v0.1.75 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2024 License: Apache-2.0 Imports: 15 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetKeyrings added in v0.1.74

func GetKeyrings() []string

GetKeyrings returns the available keyrings on the current host

func IsEncryptedToken added in v0.1.64

func IsEncryptedToken(textToken string) bool

func IsKeyringManaged added in v0.1.74

func IsKeyringManaged() (keyring string, ok bool)

IsKeyringManaged returns the keyring name and a boolean indicating if the config is managed by the keyring.

func Location

func Location() (path string, err error)

Location returns the location of the configuration file. If a configuration file already exists in the HOME directory, it uses that, otherwise it prefers to use the XDG config directory.

func ParseToken added in v0.1.64

func ParseToken(textToken string) (token *jwt.Token, err error)

func Save

func Save(cfg *Config) error

Save saves the given configuration to the configuration file.

func TokenType added in v0.1.64

func TokenType(token *jwt.Token) (typ string, err error)

TokenType extracts the value of the `typ` claim. It returns the value as a string, or the empty string if there is no such claim.

Types

type Config

type Config struct {
	// TODO(efried): Better docs for things like AccessToken
	// TODO(efried): Dedup with flag docs in cmd/ocm/login/cmd.go:init where possible
	AccessToken  string   `json:"access_token,omitempty" doc:"Bearer access token."`
	ClientID     string   `json:"client_id,omitempty" doc:"OpenID client identifier."`
	ClientSecret string   `json:"client_secret,omitempty" doc:"OpenID client secret."`
	Insecure     bool     `` /* 142-byte string literal not displayed */
	Password     string   `json:"password,omitempty" doc:"User password."`
	RefreshToken string   `json:"refresh_token,omitempty" doc:"Offline or refresh token."`
	Scopes       []string `` /* 172-byte string literal not displayed */
	TokenURL     string   `json:"token_url,omitempty" doc:"OpenID token URL."`
	URL          string   `` /* 162-byte string literal not displayed */
	User         string   `json:"user,omitempty" doc:"User name."`
	Pager        string   `json:"pager,omitempty" doc:"Pager command, for example 'less'. If empty no pager will be used."`
}

Config is the type used to store the configuration of the client. There's no way to line-split or predefine tags, so... nolint:lll

func Load

func Load() (cfg *Config, err error)

Load loads the configuration from the OS keyring first if available, load from the configuration file if not

func (*Config) Armed added in v0.1.17

func (c *Config) Armed() (armed bool, reason string, err error)

Armed checks if the configuration contains either credentials or tokens that haven't expired, so that it can be used to perform authenticated requests.

func (*Config) Connection added in v0.1.17

func (c *Config) Connection() (connection *sdk.Connection, err error)

Connection creates a connection using this configuration.

func (*Config) Disarm added in v0.1.55

func (c *Config) Disarm()

Disarm removes from the configuration all the settings that are needed for authentication.

type JWETokenHeader added in v0.1.64

type JWETokenHeader struct {
	Algorithm   string `json:"alg"`
	Encryption  string `json:"enc"`
	ContentType string `json:"cty,omitempty"`
}

Jump to

Keyboard shortcuts

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