keychain

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: MIT Imports: 9 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 keychain stores beszelscope's tokens in the macOS login Keychain through /usr/bin/security. Items are generic passwords with service Service and the hub host as the account. Any program running as the user can read them through `security` without a prompt; that trade is deliberate.

Index

Constants

View Source
const Service = "beszelscope"

Service is the Keychain service name of every beszelscope item.

Variables

View Source
var ErrNotFound = errors.New("no token in the Keychain")

ErrNotFound means there is no item for the account.

Functions

This section is empty.

Types

type Keychain

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

Keychain reads and writes beszelscope items.

func New

func New(run Runner) *Keychain

New returns a Keychain that runs commands with run, usually Security.

func (*Keychain) Delete

func (k *Keychain) Delete(ctx context.Context, account string) error

Delete removes the token for account.

func (*Keychain) Get

func (k *Keychain) Get(ctx context.Context, account string) (string, error)

Get returns the token for account.

func (*Keychain) List

func (k *Keychain) List(ctx context.Context) ([]string, error)

List returns the accounts that have a beszelscope item, sorted. It reads item attributes only, never a token.

func (*Keychain) Set

func (k *Keychain) Set(ctx context.Context, account, token string) error

Set replaces any token for account with token. It deletes and re-adds the item rather than updating it, so an old item's access rules do not survive.

type Result

type Result struct {
	Stdout string
	Stderr string
	Code   int // exit code
}

Result is what one run of /usr/bin/security produced.

func Security

func Security(ctx context.Context, stdin string, args ...string) (Result, error)

Security runs /usr/bin/security with an empty environment.

type Runner

type Runner func(ctx context.Context, stdin string, args ...string) (Result, error)

Runner runs /usr/bin/security with args and stdin. It returns an error only when the process did not run to exit; a non-zero exit is a Result.

Jump to

Keyboard shortcuts

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