vault

package
v0.0.0-...-e32210a Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const TokenKeyringSuffix = "-TokenInfo"

Variables

View Source
var ErrNotFound = keyring.ErrKeyNotFound

Functions

This section is empty.

Types

type Config

type Config struct {
	Name                  string
	GrantType             string
	AuthorizationEndpoint string
	TokenEndpoint         string
	RedirectURI           string
	Scope                 string
	ContentType           string
	UserAgent             string
}

type ConfigFile

type ConfigFile struct {
	Path string
	// contains filtered or unexported fields
}

func LoadConfig

func LoadConfig() (*ConfigFile, error)

func (*ConfigFile) Add

func (c *ConfigFile) Add(profile ProfileSection) error

Add the profile to the configuration file

func (*ConfigFile) ProfileNames

func (c *ConfigFile) ProfileNames() []string

func (*ConfigFile) ProfileSection

func (c *ConfigFile) ProfileSection(name string) (ProfileSection, bool)

ProfileSection returns the profile section with the matching name. If there isn't any, an empty profile with the provided name is returned, along with false.

func (*ConfigFile) ProfileSections

func (c *ConfigFile) ProfileSections() []ProfileSection

ProfileSections returns all the profile sections in the config

func (*ConfigFile) Save

func (c *ConfigFile) Save() error

type ConfigLoader

type ConfigLoader struct {
	File          *ConfigFile
	ActiveProfile string
}

func NewConfigLoader

func NewConfigLoader(file *ConfigFile, activeProfile string) *ConfigLoader

func (*ConfigLoader) GetProfileConfig

func (cl *ConfigLoader) GetProfileConfig(profileName string) (*Config, error)

type CredentialKeyring

type CredentialKeyring struct {
	Keyring keyring.Keyring
}

func (*CredentialKeyring) Get

func (ck *CredentialKeyring) Get(credentialsName string) (creds *Credentials, err error)

func (*CredentialKeyring) Remove

func (ck *CredentialKeyring) Remove(credentialsName string) error

func (*CredentialKeyring) Set

func (ck *CredentialKeyring) Set(credentialsName string, creds Credentials) error

type Credentials

type Credentials struct {
	ClientId     string
	ClientSecret string
	Username     string
	Password     string
}

type ProfileSection

type ProfileSection struct {
	Name                    string `ini:"-"`
	GrantType               string `ini:"grant_type"`
	AuthServerAuthEndpoint  string `ini:"auth_server_auth_endpoint"`
	AuthServerTokenEndpoint string `ini:"auth_server_token_endpoint"`
	Redirect                string `ini:"redirect"`
	Scope                   string `ini:"scopes"`
	ContentType             string `ini:"content_type"`
	UserAgent               string `ini:"user_agent"`
}

ProfileSection is a profile section of the config file

func (ProfileSection) IsEmpty

func (s ProfileSection) IsEmpty() bool

type TokenInfo

type TokenInfo struct {
	Tokens *Tokens
	// RequestTime is the time when the token was requested
	RequestTimestamp int64
}

func (*TokenInfo) IsExpired

func (t *TokenInfo) IsExpired() bool

type TokenKeyring

type TokenKeyring struct {
	Keyring keyring.Keyring
}

func (*TokenKeyring) Get

func (tkr *TokenKeyring) Get(profileName string) (tokenInfo *TokenInfo, err error)

func (*TokenKeyring) Remove

func (tkr *TokenKeyring) Remove(profileName string) error

func (*TokenKeyring) Set

func (tkr *TokenKeyring) Set(profileName string, tokenInfo *TokenInfo) error

type Tokens

type Tokens struct {
	AccessToken  string `json:"access_token"`
	IdToken      string `json:"id_token"`
	TokenType    string `json:"token_type"`
	RefreshToken string `json:"refresh_token"`
	Scope        string `json:"scope"`
	ExpiresIn    *int64 `json:"expires_in"`
	Expires      *int64 `json:"expires"` // broken Facebook spelling of expires_in
}

Jump to

Keyboard shortcuts

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