auth

package
v0.48.0 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OpenAICodexProviderID = "openai-codex"
)

Variables

This section is empty.

Functions

func AuthPath

func AuthPath() string

func ExtractAccountID

func ExtractAccountID(token string) string

func FetchOAuthAuthorizationCode

func FetchOAuthAuthorizationCode(ctx context.Context, authURL, redirectURL string, openBrowser BrowserOpener) (string, string, error)

func GenerateState

func GenerateState() (string, error)

func OpenDefaultBrowser

func OpenDefaultBrowser(rawURL string) error

Types

type BrowserOpener

type BrowserOpener func(url string) error

type OAuthCredential

type OAuthCredential struct {
	Type         string    `json:"type"`
	AccessToken  string    `json:"access_token"`
	RefreshToken string    `json:"refresh_token"`
	ExpiresAt    time.Time `json:"expires_at"`
	AccountID    string    `json:"account_id,omitempty"`
}

type OAuthLoginSession

type OAuthLoginSession struct {
	AuthURL string
	// contains filtered or unexported fields
}

func (*OAuthLoginSession) Wait

func (s *OAuthLoginSession) Wait(ctx context.Context) error

type OAuthManager

type OAuthManager struct {
	Store       *Store
	HTTPClient  *http.Client
	OpenBrowser BrowserOpener
	Issuer      string
	ClientID    string
	RedirectURI string
	// contains filtered or unexported fields
}

func NewOAuthManager

func NewOAuthManager(store *Store) *OAuthManager

func (*OAuthManager) AuthorizationURL

func (m *OAuthManager) AuthorizationURL(challenge, state string) string

func (*OAuthManager) HasCredential

func (m *OAuthManager) HasCredential(provider string) bool

func (*OAuthManager) Login

func (m *OAuthManager) Login(ctx context.Context, provider string) error

func (*OAuthManager) StartLogin

func (m *OAuthManager) StartLogin(ctx context.Context, provider string) (*OAuthLoginSession, error)

func (*OAuthManager) ValidAccessToken

func (m *OAuthManager) ValidAccessToken(ctx context.Context, provider string) (OAuthCredential, error)

type PKCE

type PKCE struct {
	Verifier  string
	Challenge string
}

func GeneratePKCE

func GeneratePKCE() (PKCE, error)

type Store

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

func NewStore

func NewStore() *Store

func NewStoreAt

func NewStoreAt(path string) *Store

func (*Store) All

func (s *Store) All() (map[string]OAuthCredential, error)

func (*Store) Get

func (s *Store) Get(provider string) (OAuthCredential, bool, error)

func (*Store) Remove

func (s *Store) Remove(provider string) error

func (*Store) Set

func (s *Store) Set(provider string, cred OAuthCredential) error

Jump to

Keyboard shortcuts

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