Documentation
¶
Index ¶
- Constants
- Variables
- func APIURL() string
- func CheckDestination(stored, current string) error
- func Revoke(ctx context.Context, credential *Credential) error
- type ActAsSession
- type Credential
- type OAuth
- type SecretStore
- type Store
- func (s Store) ActAsPath() string
- func (s Store) ClearActAs(ctx context.Context) (*ActAsSession, error)
- func (s Store) Delete() error
- func (s Store) Load() (*Credential, []byte, error)
- func (s Store) LoadActAs() (*ActAsSession, []byte, error)
- func (s Store) LockActAs(ctx context.Context) (func(), error)
- func (s Store) Read(apiURL string) (*Credential, error)
- func (s Store) Save(credential Credential, expected []byte) error
- func (s Store) SaveActAs(session ActAsSession, expected []byte) error
Constants ¶
const ClientID = "bruin-cli"
const DefaultAPIURL = "https://cloud.getbruin.com/api/v1"
Variables ¶
var ErrLegacyTokenNotRemoved = errors.New("could not remove the previous token from the OS credential store; delete the \"bruin-cloud\" item there if you no longer need it")
ErrLegacyTokenNotRemoved means the login was saved, but a token an older version kept in the OS credential store could not be removed. The new login works; the old token only lingers in the credential store.
Functions ¶
func CheckDestination ¶
Types ¶
type ActAsSession ¶ added in v0.11.818
type Credential ¶
type Credential struct {
Token string `json:"access_token"`
TokenType string `json:"token_type"`
TokenID string `json:"token_id"`
Account string `json:"account"`
DefaultTeam string `json:"default_team"`
ExpiresAt time.Time `json:"expires_at"`
Abilities []string `json:"abilities"`
Teams []string `json:"teams"`
APIURL string `json:"-"`
// contains filtered or unexported fields
}
type OAuth ¶
type SecretStore ¶
type Store ¶
type Store struct {
Path string
// Open opens the OS credential store. It is only used to migrate logins saved by older versions.
Open func() (SecretStore, error)
}
Store keeps the global login in cloud.yml. The token is written to the file itself (0600 inside a 0700 directory). Older versions kept the token in the OS credential store and wrote a keyring:// pointer to the file instead; such logins are moved into the file the first time they are read.
func DefaultStore ¶
func (Store) ClearActAs ¶ added in v0.11.818
func (s Store) ClearActAs(ctx context.Context) (*ActAsSession, error)
ClearActAs removes the session file even when it is corrupt, returning an empty session in that case.
func (Store) Load ¶
func (s Store) Load() (*Credential, []byte, error)
Load returns the configured global login without contacting the OS credential store, so a login saved by an older version comes back with an empty Token and a credential-store pointer.
func (Store) LoadActAs ¶ added in v0.11.818
func (s Store) LoadActAs() (*ActAsSession, []byte, error)
LoadActAs also returns the raw file so a later save can detect concurrent changes.
func (Store) LockActAs ¶ added in v0.11.818
LockActAs serialises session changes across bruin processes; reads need no lock.