auth

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package auth manages spoo CLI credentials and the device-auth login flow.

Index

Constants

View Source
const (
	// AppID matches the spoo-cli entry in the backend's config/apps.yaml.
	AppID = "spoo-cli"
	// CallbackAddr is fixed: the backend validates redirect_uri by exact
	// match against the registry, so a random port would be rejected.
	CallbackAddr = "127.0.0.1:53682"
	CallbackPath = "/callback"
)

Variables

View Source
var ErrNotLoggedIn = errors.New("not logged in — run `spoo auth login`")

Functions

This section is empty.

Types

type Credentials

type Credentials struct {
	Mode         Mode   `json:"mode"`
	AccessToken  string `json:"access_token,omitempty"`
	RefreshToken string `json:"refresh_token,omitempty"`
	APIKey       string `json:"api_key,omitempty"`
}

type DeviceFlow

type DeviceFlow struct {
	APIBase     string
	OpenBrowser func(url string) error
	Out         io.Writer // progress messages (stderr)
}

DeviceFlow drives the spoo.me connected-apps device authorization: loopback server → browser consent → one-time code.

func (*DeviceFlow) Run

func (f *DeviceFlow) Run(ctx context.Context) (string, string, error)

Run blocks until the consent callback delivers a code, the context expires, or the callback is invalid. Returns the one-time code and the PKCE verifier that must accompany it in the token exchange.

type Mode

type Mode string
const (
	ModeDevice Mode = "device"  // JWT pair from the connected-apps device flow
	ModeAPIKey Mode = "api_key" // spoo_... API key (non-interactive / CI)
)

type Store

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

Store persists credentials in the OS keyring, falling back to a 0600 file in the config dir when no keyring is available.

func NewStore

func NewStore(configDir string) *Store

func (*Store) Clear

func (s *Store) Clear() error

func (*Store) Load

func (s *Store) Load() (*Credentials, error)

func (*Store) Save

func (s *Store) Save(c Credentials) error

Jump to

Keyboard shortcuts

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