Documentation
¶
Index ¶
- Variables
- func CallbackPort(addr net.Addr) int
- func DefaultCredPath(issuer string) (string, error)
- func HostFromIssuer(issuer string) (string, error)
- type CredStore
- func (s *CredStore) DeleteAll() error
- func (s *CredStore) DeleteHost(host string) error
- func (s *CredStore) Hosts() ([]string, error)
- func (s *CredStore) LoadCurrent() (string, Credentials, error)
- func (s *CredStore) LoadHost(host string) (Credentials, error)
- func (s *CredStore) Path() string
- func (s *CredStore) SaveHost(host string, creds Credentials) error
- func (s *CredStore) UseHost(host string) error
- type Credentials
- type Endpoints
- type Login
- type LoginOptions
- type LoopbackOptions
- type PasteOptions
Constants ¶
This section is empty.
Variables ¶
var ErrNotLoggedIn = errors.New("cliauth: not logged in")
ErrNotLoggedIn is returned when no credentials exist for the requested host.
Functions ¶
func CallbackPort ¶
CallbackPort returns a TCP port from addr when available.
func DefaultCredPath ¶
DefaultCredPath returns the standard issuer-scoped credentials path.
func HostFromIssuer ¶
HostFromIssuer returns the canonical host key for an issuer URL.
Types ¶
type CredStore ¶
type CredStore struct {
// contains filtered or unexported fields
}
CredStore persists OAuth credentials for one or more hosts.
func NewCredStore ¶
NewCredStore returns a store backed by path.
func (*CredStore) DeleteHost ¶
DeleteHost removes one host. If it was current, current advances by sort order.
func (*CredStore) LoadCurrent ¶
func (s *CredStore) LoadCurrent() (string, Credentials, error)
LoadCurrent returns the current host and its credentials.
func (*CredStore) LoadHost ¶
func (s *CredStore) LoadHost(host string) (Credentials, error)
LoadHost returns the credentials for host.
type Credentials ¶
type Credentials struct {
Issuer string `json:"issuer"`
ClientID string `json:"client_id"`
RedirectURIs []string `json:"redirect_uris,omitempty"`
AccessToken string `json:"access_token,omitempty"`
RefreshToken string `json:"refresh_token,omitempty"`
ExpiresAt time.Time `json:"expires_at,omitzero"`
Scope string `json:"scope,omitempty"`
}
Credentials is one issuer host's persisted OAuth state.
func (Credentials) NeedsRefresh ¶
func (c Credentials) NeedsRefresh() bool
NeedsRefresh reports whether the access token should be refreshed before use.
type Endpoints ¶
Endpoints contains OAuth endpoints discovered from the issuer or supplied by callers.
type Login ¶
type Login struct {
Issuer string
Store *CredStore
HTTPClient *http.Client
OpenURL func(url string) error
Endpoints Endpoints
}
Login orchestrates the OAuth/PKCE flow against an MCP server.
func NewLogin ¶
func NewLogin(opts LoginOptions) (*Login, error)
NewLogin returns a Login configured for issuer.
func (*Login) GetAccessToken ¶
GetAccessToken returns a valid access token, refreshing first if needed.
func (*Login) RunLoopback ¶
func (l *Login) RunLoopback(ctx context.Context, opts LoopbackOptions) error
RunLoopback performs the auto-browser PKCE loopback flow.
func (*Login) RunPasteRedirect ¶
func (l *Login) RunPasteRedirect(ctx context.Context, opts PasteOptions) error
RunPasteRedirect performs a PKCE flow where the user pastes the redirect URL.
type LoginOptions ¶
type LoginOptions struct {
Issuer string
CredPath string
Store *CredStore
HTTPClient *http.Client
OpenURL func(url string) error
Endpoints Endpoints
}
LoginOptions configures a CLI OAuth helper.
type LoopbackOptions ¶
LoopbackOptions configures the auto-browser PKCE loopback flow.