auth

package
v0.1.0-beta.3 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2026 License: MIT Imports: 8 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 ErrLoginRequired = errors.New("login required")

Functions

This section is empty.

Types

type ConfigLoader

type ConfigLoader interface {
	Load() (projectconfig.Config, error)
}

type Locker

type Locker interface {
	Lock(ctx context.Context, key string) (unlock func() error, err error)
}

type LoginOptions

type LoginOptions struct {
	Manual bool
}

type Manager

type Manager struct {
	Tokens        TokenRepository
	Locker        Locker
	Refresh       func(context.Context, credential.Token) (oauth.TokenResponse, error)
	Now           func() time.Time
	RefreshBefore time.Duration
}

func (Manager) EnsureFresh

func (m Manager) EnsureFresh(ctx context.Context, profile string) (credential.Token, error)

func (Manager) RefreshNow

func (m Manager) RefreshNow(ctx context.Context, profile string) (credential.Token, error)

func (Manager) Supervise

func (m Manager) Supervise(ctx context.Context, profile string, interval time.Duration, onError func(error))

Supervise refreshes credentials for future API requests. Its context belongs to the supervisor, not to an established SSH session, so a refresh failure is reported but never closes an active connection.

type Service

type Service struct {
	Config    ConfigLoader
	Tokens    TokenRepository
	Manager   Manager
	LoginFlow func(context.Context, string) (credential.Token, error)
	// ManualLoginFlow 是其他程序占用私有协议或系统禁止注册协议时永久保留的回退方式。
	ManualLoginFlow func(context.Context, string) (credential.Token, error)
	Revoke          func(context.Context, credential.Token) error
	Now             func() time.Time
	Timeout         time.Duration
}

func (Service) Login

func (s Service) Login(ctx context.Context, requestedProfile string, options LoginOptions) (Status, error)

func (Service) Logout

func (s Service) Logout(ctx context.Context, requestedProfile string) error

func (Service) Refresh

func (s Service) Refresh(ctx context.Context, requestedProfile string) (Status, error)

func (Service) Status

func (s Service) Status(requestedProfile string) (Status, error)

type Status

type Status struct {
	Profile          string
	LoggedIn         bool
	Expired          bool
	RefreshAvailable bool
	ExpiresAt        time.Time
}

type TokenRepository

type TokenRepository interface {
	Load(profile string) (credential.Token, error)
	Save(profile string, token credential.Token) error
	Delete(profile string) error
}

Jump to

Keyboard shortcuts

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