Documentation
¶
Index ¶
- Variables
- type ConfigLoader
- type Locker
- type LoginOptions
- type Manager
- type Service
- func (s Service) Login(ctx context.Context, requestedProfile string, options LoginOptions) (Status, error)
- func (s Service) Logout(ctx context.Context, requestedProfile string) error
- func (s Service) Refresh(ctx context.Context, requestedProfile string) (Status, error)
- func (s Service) Status(requestedProfile string) (Status, error)
- type Status
- type TokenRepository
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 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 (Manager) RefreshNow ¶
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
}
type TokenRepository ¶
type TokenRepository interface {
Load(profile string) (credential.Token, error)
Save(profile string, token credential.Token) error
Delete(profile string) error
}
Click to show internal directories.
Click to hide internal directories.