auth

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: AGPL-3.0 Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package auth implements the device-flow client and token storage.

Index

Constants

This section is empty.

Variables

View Source
var ErrDenied = errors.New("device was denied in the browser")

ErrDenied is returned when the user denied the device in the browser.

View Source
var ErrExpired = errors.New("code expired, run braid login again")

ErrExpired is returned when the device code expired.

View Source
var ErrNoKeychain = errors.New("no OS keychain available")

ErrNoKeychain means the OS keychain backend is unavailable.

View Source
var ErrNoToken = errors.New("not logged in")

ErrNoToken means no token is stored for the server.

Functions

func Login

Login runs the device flow: POST code, call show(resp), poll every interval (+5 s on slow_down) until success, access_denied, expired_token or ctx end. Response bodies are never included in errors.

Types

type Store

type Store interface {
	Get(server string) (string, error) // ErrNoToken if absent
	Set(server, token string) error
	Delete(server string) error
	Kind() string // "keychain" | "file"
}

Store keeps one device token per server URL.

func NewFile

func NewFile(configDir string) Store

NewFile stores tokens in <configDir>/token as JSON {server: token} with mode 0600 (dir 0700); refuses to read a file with group/other permission bits (unix).

func NewKeychain

func NewKeychain() Store

NewKeychain uses go-keyring service "braid", user = server URL; Set returns ErrNoKeychain when the backend is unavailable.

Jump to

Keyboard shortcuts

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