Documentation
¶
Overview ¶
Package authenticator provides concrete Authenticator implementations for CLI login flows.
Package authenticator provides concrete Authenticator implementations for CLI login flows.
Package authenticator provides concrete Authenticator implementations for CLI login flows.
Index ¶
- func NewClaudeAuthenticator() (cliauth.Authenticator, error)
- func NewCodexAuthenticator() (cliauth.Authenticator, error)
- func NewGeminiAuthenticator() (cliauth.Authenticator, error)
- type AuthErrorCode
- type AuthenticationError
- type ClaudeAuthenticator
- func (a *ClaudeAuthenticator) GetConfig() cliauth.AuthenticatorConfig
- func (a *ClaudeAuthenticator) Login(ctx context.Context, _ cliauth.LoginRequest, ...) (*credentialmgr.Credential, error)
- func (a *ClaudeAuthenticator) Refresh(ctx context.Context, cred *credentialmgr.Credential) (*credentialmgr.Credential, error)
- func (a *ClaudeAuthenticator) RefreshLeadTime() *time.Duration
- func (a *ClaudeAuthenticator) SetConfig(cfg cliauth.AuthenticatorConfig) error
- type CodexAuthenticator
- func (a *CodexAuthenticator) GetConfig() cliauth.AuthenticatorConfig
- func (a *CodexAuthenticator) Login(ctx context.Context, _ cliauth.LoginRequest, ...) (*credentialmgr.Credential, error)
- func (a *CodexAuthenticator) Refresh(ctx context.Context, cred *credentialmgr.Credential) (*credentialmgr.Credential, error)
- func (a *CodexAuthenticator) RefreshLeadTime() *time.Duration
- func (a *CodexAuthenticator) SetConfig(cfg cliauth.AuthenticatorConfig) error
- type GeminiAuthenticator
- func (a *GeminiAuthenticator) GetConfig() cliauth.AuthenticatorConfig
- func (a *GeminiAuthenticator) Login(ctx context.Context, _ cliauth.LoginRequest, ...) (*credentialmgr.Credential, error)
- func (a *GeminiAuthenticator) Refresh(ctx context.Context, cred *credentialmgr.Credential) (*credentialmgr.Credential, error)
- func (a *GeminiAuthenticator) RefreshLeadTime() *time.Duration
- func (a *GeminiAuthenticator) SetConfig(cfg cliauth.AuthenticatorConfig) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewClaudeAuthenticator ¶
func NewClaudeAuthenticator() (cliauth.Authenticator, error)
NewClaudeAuthenticator creates a ClaudeAuthenticator with default settings.
func NewCodexAuthenticator ¶
func NewCodexAuthenticator() (cliauth.Authenticator, error)
NewCodexAuthenticator creates a CodexAuthenticator with default settings.
func NewGeminiAuthenticator ¶
func NewGeminiAuthenticator() (cliauth.Authenticator, error)
NewGeminiAuthenticator creates a GeminiAuthenticator with default settings.
Types ¶
type AuthErrorCode ¶
type AuthErrorCode string
AuthErrorCode identifies the category of a login-flow error.
const ( ErrPortInUse AuthErrorCode = "port_in_use" ErrServerStartFailed AuthErrorCode = "server_start_failed" ErrCallbackTimeout AuthErrorCode = "callback_timeout" ErrInvalidState AuthErrorCode = "invalid_state" ErrCodeExchangeFailed AuthErrorCode = "code_exchange_failed" )
type AuthenticationError ¶
type AuthenticationError struct {
Code AuthErrorCode
Wrapped error
}
AuthenticationError carries a typed error code alongside the underlying cause.
func (*AuthenticationError) Error ¶
func (e *AuthenticationError) Error() string
func (*AuthenticationError) Unwrap ¶
func (e *AuthenticationError) Unwrap() error
type ClaudeAuthenticator ¶
type ClaudeAuthenticator struct {
cliauth.AuthenticatorConfig
// HTTPClient is the HTTP client used for token requests. If nil, http.DefaultClient is used.
HTTPClient *http.Client
// contains filtered or unexported fields
}
ClaudeAuthenticator implements manager.Authenticator for the Anthropic Claude Code CLI login flow. It uses browser-based OAuth PKCE authentication against the Anthropic OAuth endpoints.
func (*ClaudeAuthenticator) GetConfig ¶
func (a *ClaudeAuthenticator) GetConfig() cliauth.AuthenticatorConfig
GetConfig returns the current runtime configuration for the authenticator.
func (*ClaudeAuthenticator) Login ¶
func (a *ClaudeAuthenticator) Login(ctx context.Context, _ cliauth.LoginRequest, reporter cliauth.LoginStatusReporter) (*credentialmgr.Credential, error)
Login initiates the Claude Code CLI login flow and returns a new credential on success.
func (*ClaudeAuthenticator) Refresh ¶
func (a *ClaudeAuthenticator) Refresh(ctx context.Context, cred *credentialmgr.Credential) (*credentialmgr.Credential, error)
Refresh refreshes the credential's access token before it expires. Returns nil if no refresh token is present.
func (*ClaudeAuthenticator) RefreshLeadTime ¶
func (a *ClaudeAuthenticator) RefreshLeadTime() *time.Duration
RefreshLeadTime returns how far in advance of token expiry to refresh Claude Code credentials.
func (*ClaudeAuthenticator) SetConfig ¶
func (a *ClaudeAuthenticator) SetConfig(cfg cliauth.AuthenticatorConfig) error
SetConfig applies runtime configuration to the authenticator.
type CodexAuthenticator ¶
type CodexAuthenticator struct {
cliauth.AuthenticatorConfig
// contains filtered or unexported fields
}
CodexAuthenticator implements manager.Authenticator for the OpenAI Codex CLI login flow. It supports both browser-based OAuth PKCE and headless device flow authentication.
func (*CodexAuthenticator) GetConfig ¶
func (a *CodexAuthenticator) GetConfig() cliauth.AuthenticatorConfig
GetConfig returns the current runtime configuration for the authenticator.
func (*CodexAuthenticator) Login ¶
func (a *CodexAuthenticator) Login(ctx context.Context, _ cliauth.LoginRequest, reporter cliauth.LoginStatusReporter) (*credentialmgr.Credential, error)
Login initiates the Codex CLI login flow and returns a new credential on success. It uses browser-based OAuth PKCE by default; set UseDeviceFlow for headless environments.
func (*CodexAuthenticator) Refresh ¶
func (a *CodexAuthenticator) Refresh(ctx context.Context, cred *credentialmgr.Credential) (*credentialmgr.Credential, error)
Refresh refreshes the credential's access token before it expires. Returns nil if no refresh token is present or the credential has no expiry metadata.
func (*CodexAuthenticator) RefreshLeadTime ¶
func (a *CodexAuthenticator) RefreshLeadTime() *time.Duration
RefreshLeadTime returns how far in advance of token expiry to refresh Codex credentials. Five days gives ample runway for CLI tokens whose refresh window is typically 30 days.
func (*CodexAuthenticator) SetConfig ¶
func (a *CodexAuthenticator) SetConfig(cfg cliauth.AuthenticatorConfig) error
SetConfig applies runtime configuration to the authenticator.
type GeminiAuthenticator ¶
type GeminiAuthenticator struct {
cliauth.AuthenticatorConfig
// HTTPClient is the HTTP client used for token requests. If nil, http.DefaultClient is used.
HTTPClient *http.Client
// contains filtered or unexported fields
}
GeminiAuthenticator implements manager.Authenticator for the Google Gemini CLI login flow. It uses browser-based OAuth2 authentication against Google's OAuth endpoints.
func (*GeminiAuthenticator) GetConfig ¶
func (a *GeminiAuthenticator) GetConfig() cliauth.AuthenticatorConfig
GetConfig returns the current runtime configuration for the authenticator.
func (*GeminiAuthenticator) Login ¶
func (a *GeminiAuthenticator) Login(ctx context.Context, _ cliauth.LoginRequest, reporter cliauth.LoginStatusReporter) (*credentialmgr.Credential, error)
Login initiates the Gemini CLI login flow and returns a new credential on success.
func (*GeminiAuthenticator) Refresh ¶
func (a *GeminiAuthenticator) Refresh(ctx context.Context, cred *credentialmgr.Credential) (*credentialmgr.Credential, error)
Refresh refreshes the credential's access token before it expires. Returns nil if no refresh token is present.
func (*GeminiAuthenticator) RefreshLeadTime ¶
func (a *GeminiAuthenticator) RefreshLeadTime() *time.Duration
RefreshLeadTime returns nil to disable provider-level background pre-refresh for Gemini.
func (*GeminiAuthenticator) SetConfig ¶
func (a *GeminiAuthenticator) SetConfig(cfg cliauth.AuthenticatorConfig) error
SetConfig applies runtime configuration to the authenticator.