auth

package
v6.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2025 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrRefreshNotSupported = errors.New("cliproxy auth: refresh not supported")

Functions

func RegisterTokenStore

func RegisterTokenStore(store TokenStore)

RegisterTokenStore sets the global token store used by the authentication helpers.

Types

type Authenticator

type Authenticator interface {
	Provider() string
	Login(ctx context.Context, cfg *config.Config, opts *LoginOptions) (*TokenRecord, error)
	RefreshLead() *time.Duration
}

Authenticator manages login and optional refresh flows for a provider.

type ClaudeAuthenticator

type ClaudeAuthenticator struct {
	CallbackPort int
}

ClaudeAuthenticator implements the OAuth login flow for Anthropic Claude accounts.

func NewClaudeAuthenticator

func NewClaudeAuthenticator() *ClaudeAuthenticator

NewClaudeAuthenticator constructs a Claude authenticator with default settings.

func (*ClaudeAuthenticator) Login

func (*ClaudeAuthenticator) Provider

func (a *ClaudeAuthenticator) Provider() string

func (*ClaudeAuthenticator) RefreshLead

func (a *ClaudeAuthenticator) RefreshLead() *time.Duration

type CodexAuthenticator

type CodexAuthenticator struct {
	CallbackPort int
}

CodexAuthenticator implements the OAuth login flow for Codex accounts.

func NewCodexAuthenticator

func NewCodexAuthenticator() *CodexAuthenticator

NewCodexAuthenticator constructs a Codex authenticator with default settings.

func (*CodexAuthenticator) Login

func (*CodexAuthenticator) Provider

func (a *CodexAuthenticator) Provider() string

func (*CodexAuthenticator) RefreshLead

func (a *CodexAuthenticator) RefreshLead() *time.Duration

type EmailRequiredError

type EmailRequiredError struct {
	Prompt string
}

EmailRequiredError indicates that the calling context must provide an email or alias.

func (*EmailRequiredError) Error

func (e *EmailRequiredError) Error() string

type FileTokenStore

type FileTokenStore struct {
	// contains filtered or unexported fields
}

FileTokenStore persists token records and auth metadata using the filesystem as backing storage.

func NewFileTokenStore

func NewFileTokenStore() *FileTokenStore

NewFileTokenStore creates a token store that saves credentials to disk through the TokenStorage implementation embedded in the token record.

func (*FileTokenStore) Delete

func (s *FileTokenStore) Delete(ctx context.Context, id string) error

Delete removes the auth file.

func (*FileTokenStore) List

func (s *FileTokenStore) List(ctx context.Context) ([]*cliproxyauth.Auth, error)

List enumerates all auth JSON files under the configured directory.

func (*FileTokenStore) Save

func (s *FileTokenStore) Save(ctx context.Context, cfg *config.Config, record *TokenRecord) (string, error)

Save writes the token storage to the resolved file path.

func (*FileTokenStore) SaveAuth

func (s *FileTokenStore) SaveAuth(ctx context.Context, auth *cliproxyauth.Auth) error

SaveAuth writes the auth metadata back to its source file location.

func (*FileTokenStore) SetBaseDir

func (s *FileTokenStore) SetBaseDir(dir string)

SetBaseDir updates the default directory used for auth JSON persistence when no explicit path is provided.

type GeminiAuthenticator

type GeminiAuthenticator struct{}

GeminiAuthenticator implements the login flow for Google Gemini CLI accounts.

func NewGeminiAuthenticator

func NewGeminiAuthenticator() *GeminiAuthenticator

NewGeminiAuthenticator constructs a Gemini authenticator.

func (*GeminiAuthenticator) Login

func (*GeminiAuthenticator) Provider

func (a *GeminiAuthenticator) Provider() string

func (*GeminiAuthenticator) RefreshLead

func (a *GeminiAuthenticator) RefreshLead() *time.Duration

type GeminiWebAuthenticator

type GeminiWebAuthenticator struct{}

GeminiWebAuthenticator provides a minimal wrapper so core components can treat Gemini Web credentials via the shared Authenticator contract.

func NewGeminiWebAuthenticator

func NewGeminiWebAuthenticator() *GeminiWebAuthenticator

func (*GeminiWebAuthenticator) Login

func (*GeminiWebAuthenticator) Provider

func (a *GeminiWebAuthenticator) Provider() string

func (*GeminiWebAuthenticator) RefreshLead

func (a *GeminiWebAuthenticator) RefreshLead() *time.Duration

type LoginOptions

type LoginOptions struct {
	NoBrowser bool
	ProjectID string
	Metadata  map[string]string
	Prompt    func(prompt string) (string, error)
}

LoginOptions captures generic knobs shared across authenticators. Provider-specific logic can inspect Metadata for extra parameters.

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager aggregates authenticators and coordinates persistence via a token store.

func NewManager

func NewManager(store TokenStore, authenticators ...Authenticator) *Manager

NewManager constructs a manager with the provided token store and authenticators. If store is nil, the caller must set it later using SetStore.

func (*Manager) Login

func (m *Manager) Login(ctx context.Context, provider string, cfg *config.Config, opts *LoginOptions) (*TokenRecord, string, error)

Login executes the provider login flow and persists the resulting token record.

func (*Manager) Register

func (m *Manager) Register(a Authenticator)

Register adds or replaces an authenticator keyed by its provider identifier.

func (*Manager) SetStore

func (m *Manager) SetStore(store TokenStore)

SetStore updates the token store used for persistence.

type ProjectSelectionError

type ProjectSelectionError struct {
	Email    string
	Projects []interfaces.GCPProjectProjects
}

ProjectSelectionError indicates that the user must choose a specific project ID.

func (*ProjectSelectionError) Error

func (e *ProjectSelectionError) Error() string

func (*ProjectSelectionError) ProjectsDisplay

func (e *ProjectSelectionError) ProjectsDisplay() []interfaces.GCPProjectProjects

ProjectsDisplay returns the projects list for caller presentation.

type QwenAuthenticator

type QwenAuthenticator struct{}

QwenAuthenticator implements the device flow login for Qwen accounts.

func NewQwenAuthenticator

func NewQwenAuthenticator() *QwenAuthenticator

NewQwenAuthenticator constructs a Qwen authenticator.

func (*QwenAuthenticator) Login

func (*QwenAuthenticator) Provider

func (a *QwenAuthenticator) Provider() string

func (*QwenAuthenticator) RefreshLead

func (a *QwenAuthenticator) RefreshLead() *time.Duration

type TokenRecord

type TokenRecord struct {
	Provider string
	FileName string
	Storage  baseauth.TokenStorage
	Metadata map[string]string
}

TokenRecord represents credential material produced by an authenticator.

type TokenStore

type TokenStore interface {
	Save(ctx context.Context, cfg *config.Config, record *TokenRecord) (string, error)
}

TokenStore persists token records.

func GetTokenStore

func GetTokenStore() TokenStore

GetTokenStore returns the globally registered token store.

Jump to

Keyboard shortcuts

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