Files
CLIProxyAPI/sdk/auth/interfaces.go
whale9820 bebd92c4c8 feat(cmd): add -login-proxy flag for CLI OAuth logins
Route the CLI OAuth flow through a chosen proxy and persist it as the
new credential's proxy_url, matching the management API's session
proxy behavior.
2026-11-09 15:08:55 +08:00

31 lines
844 B
Go

package auth
import (
"context"
"errors"
"time"
"github.com/router-for-me/CLIProxyAPI/v8/internal/config"
coreauth "github.com/router-for-me/CLIProxyAPI/v8/sdk/cliproxy/auth"
)
var ErrRefreshNotSupported = errors.New("cliproxy auth: refresh not supported")
// LoginOptions captures generic knobs shared across authenticators.
// Provider-specific logic can inspect Metadata for extra parameters.
type LoginOptions struct {
NoBrowser bool
ProjectID string
CallbackPort int
Metadata map[string]string
Prompt func(prompt string) (string, error)
ProxyURL string
}
// Authenticator manages login and optional refresh flows for a provider.
type Authenticator interface {
Provider() string
Login(ctx context.Context, cfg *config.Config, opts *LoginOptions) (*coreauth.Auth, error)
RefreshLead() *time.Duration
}