mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-03 04:50:52 +08:00
- Replaced `TokenRecord` with `coreauth.Auth` for centralized and consistent authentication data structures. - Migrated `TokenStore` interface to `coreauth.Store` for alignment with core CLIProxy authentication. - Updated related login methods, token persistence logic, and file storage handling to use the new `coreauth.Auth` model.
29 lines
793 B
Go
29 lines
793 B
Go
package auth
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"time"
|
|
|
|
"github.com/router-for-me/CLIProxyAPI/v6/internal/config"
|
|
coreauth "github.com/router-for-me/CLIProxyAPI/v6/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
|
|
Metadata map[string]string
|
|
Prompt func(prompt string) (string, error)
|
|
}
|
|
|
|
// 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
|
|
}
|