credential

package
v0.2.0-pre.3 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: MIT Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("credential not found")

Functions

This section is empty.

Types

type Backend

type Backend interface {
	Get(key string) ([]byte, error)
	Set(key string, value []byte) error
	Delete(key string) error
}

func NewFileBackend

func NewFileBackend(directory string) Backend

NewFileBackend stores each opaque credential key in its own private file. The key is hashed instead of normalized so character replacement cannot collapse distinct profile names to the same filesystem name.

type Repository

type Repository struct {
	Backend Backend
}

func (Repository) Delete

func (r Repository) Delete(profile string) error

func (Repository) Load

func (r Repository) Load(profile string) (Token, error)

func (Repository) Save

func (r Repository) Save(profile string, token Token) error

type Token

type Token struct {
	LoginID      string    `json:"login_id,omitempty"`
	AccessToken  string    `json:"access_token"`
	RefreshToken string    `json:"refresh_token"`
	TokenType    string    `json:"token_type,omitempty"`
	ClientID     string    `json:"client_id"`
	Site         string    `json:"site"`
	ExpiresAt    time.Time `json:"expires_at"`
	RefreshedAt  time.Time `json:"refreshed_at"`
}

Token 保存于私有凭据文件,不得写入普通配置或日志。

Jump to

Keyboard shortcuts

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