Documentation
¶
Index ¶
- Variables
- func IsMissingCredentials(err error) bool
- type AuthorizationServerMetadata
- type CredentialStore
- type Credentials
- type Discovery
- type LoginOptions
- type LogoutResult
- type ProfileStore
- type ProtectedResourceMetadata
- type Registration
- type Service
- func (s *Service) AccessToken(ctx context.Context, profile string) (string, error)
- func (s *Service) Login(ctx context.Context, opts LoginOptions) (Status, error)
- func (s *Service) Logout(ctx context.Context, profile string) (LogoutResult, error)
- func (s *Service) Refresh(ctx context.Context, profile string) (Status, error)
- func (s *Service) Status(profile string) (Status, error)
- type Status
- type Store
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrReauthenticationRequired = errors.New("reauthentication is required")
ErrReauthenticationRequired identifies an unusable grant that needs explicit user sign-in. Network failures and transient provider errors do not match it.
Functions ¶
func IsMissingCredentials ¶
Types ¶
type AuthorizationServerMetadata ¶
type AuthorizationServerMetadata struct {
Issuer string `json:"issuer"`
AuthorizationEndpoint string `json:"authorization_endpoint"`
TokenEndpoint string `json:"token_endpoint"`
RevocationEndpoint string `json:"revocation_endpoint,omitempty"`
RegistrationEndpoint string `json:"registration_endpoint"`
ScopesSupported []string `json:"scopes_supported"`
ResponseTypesSupported []string `json:"response_types_supported"`
GrantTypesSupported []string `json:"grant_types_supported"`
TokenEndpointAuthMethodsSupported []string `json:"token_endpoint_auth_methods_supported"`
CodeChallengeMethodsSupported []string `json:"code_challenge_methods_supported"`
}
type CredentialStore ¶
type CredentialStore interface {
Load(profileName string) (Credentials, error)
Save(profileName string, credentials Credentials) error
Delete(profileName string) error
UsingKeyring() bool
Warning() string
}
type Credentials ¶
type Credentials struct {
AccessToken string `json:"access_token"`
RefreshToken string `json:"refresh_token,omitempty"`
TokenType string `json:"token_type"`
Scope string `json:"scope"`
ExpiresAt time.Time `json:"expires_at"`
ClientID string `json:"client_id"`
ClientSecret string `json:"client_secret,omitempty"`
Issuer string `json:"issuer"`
Resource string `json:"resource"`
}
type Discovery ¶
type Discovery struct {
Resource ProtectedResourceMetadata `json:"resource_metadata"`
Authorization AuthorizationServerMetadata `json:"authorization_server_metadata"`
}
type LoginOptions ¶
type LogoutResult ¶
type ProfileStore ¶
type ProfileStore interface {
SnapshotProfile(string) (config.ProfileSnapshot, error)
UpsertProfile(config.Profile) error
RestoreProfile(config.ProfileSnapshot) error
}
type Registration ¶
type Registration struct {
ClientID string `json:"client_id"`
ClientSecret string `json:"client_secret,omitempty"`
ClientIDIssuedAt int64 `json:"client_id_issued_at"`
ClientSecretExpiresAt int64 `json:"client_secret_expires_at,omitempty"`
ClientName string `json:"client_name"`
RedirectURIs []string `json:"redirect_uris"`
GrantTypes []string `json:"grant_types"`
ResponseTypes []string `json:"response_types"`
TokenEndpointAuthMethod string `json:"token_endpoint_auth_method"`
Scope string `json:"scope"`
}
type Service ¶
type Service struct {
Config ProfileStore
Credentials CredentialStore
HTTPClient *http.Client
OpenBrowser func(string) error
Now func() time.Time
Discover func(context.Context, *http.Client) (Discovery, error)
}
func NewService ¶
func NewService(cfg *config.Store, credentials CredentialStore) *Service
func (*Service) AccessToken ¶
type Status ¶
type Status struct {
Profile string `json:"profile"`
Authenticated bool `json:"authenticated"`
ExpiresAt time.Time `json:"expires_at,omitempty"`
Expired bool `json:"expired,omitempty"`
Refreshable bool `json:"-"`
Scope string `json:"scope,omitempty"`
Issuer string `json:"issuer,omitempty"`
Resource string `json:"resource,omitempty"`
Storage string `json:"storage,omitempty"`
Warning string `json:"warning,omitempty"`
}
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
func NewCredentialStore ¶
func (*Store) UsingKeyring ¶
Click to show internal directories.
Click to hide internal directories.