admin

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package admin manages the read API's bearer-token file.

On first run we create data/admin_token with a fresh random token (256 bits, hex-encoded). On subsequent runs we read it. ARCHITECTURE § 6 says: "auto-generated on first run; print to stdout once at startup; if deleted, regenerate on next startup and print again".

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareConst

func CompareConst(want, got string) bool

CompareConst constant-time compares two tokens. Use this in the authentication middleware to avoid timing leaks per SECURITY.md threat model.

The expected token is the 64-char hex value generated by EnsureToken; its length is a fixed public constant of the project. Any candidate whose length differs is rejected up front — there is no length to leak. subtle.ConstantTimeCompare then runs on equal-length inputs.

func EnsureToken

func EnsureToken(dataDir string) (token string, generated bool, err error)

EnsureToken returns the admin bearer token at data/admin_token, creating one if absent. Returns (token, generated, error) — caller uses `generated` to decide whether to print the token to stdout.

Types

This section is empty.

Jump to

Keyboard shortcuts

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