webkey

package
v2.4.11 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package webkey manages the dedicated web-surface access credential for the embedded web UI. It is a separate credential namespace: the web key is never used as, defaulted to, or derived from http.token or the sync token.

Index

Constants

View Source
const (
	// DefaultFileName is the conventional web key file name inside the Cortex
	// configuration directory.
	DefaultFileName = "web.key"
)

Variables

View Source
var (
	// ErrKeyNotFound indicates no web key file exists at the store path.
	ErrKeyNotFound = errors.New("webkey: web access key file not found")
	// ErrKeyExists indicates the web key file is already present.
	ErrKeyExists = errors.New("webkey: web access key file already exists")
	// ErrInvalidKey is the deterministic rejection for any failed verification.
	ErrInvalidKey = errors.New("webkey: invalid web access key")
	// ErrMalformedKeyFile indicates the key file cannot be parsed.
	ErrMalformedKeyFile = errors.New("webkey: malformed web key file")
	// ErrInsecurePermissions indicates the key file is group/other readable.
	ErrInsecurePermissions = errors.New("webkey: web key file permissions too permissive")
)

Functions

This section is empty.

Types

type Record

type Record struct {
	Prefix string
	Digest string
}

Record is the non-secret at-rest representation of a web access key. It never carries the plaintext secret.

type Store

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

Store owns a single web key file at a caller-supplied path.

func NewStore

func NewStore(path string) (*Store, error)

NewStore returns a Store bound to path. The path is never defaulted or read from global configuration; callers pass an explicit location.

func (*Store) EnsureFirstBoot

func (s *Store) EnsureFirstBoot() (string, bool, error)

EnsureFirstBoot mints and persists a key when none exists, returning the plaintext with minted=true exactly once. When a key already exists, including the loser of a concurrent first boot, it returns minted=false and no plaintext.

func (*Store) Exists

func (s *Store) Exists() (bool, error)

Exists reports whether a key file is present without revealing its contents.

func (*Store) Generate

func (s *Store) Generate() (string, error)

Generate mints a new web key, persists it with an exclusive create, and returns the plaintext exactly once. It fails with ErrKeyExists when a key file already exists and never leaves a partial file behind.

func (*Store) Load

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

Load reads and validates the persisted record without exposing the secret.

func (*Store) Path

func (s *Store) Path() string

Path reports the key file location.

func (*Store) Regenerate

func (s *Store) Regenerate() (string, error)

Regenerate atomically replaces the persisted key with a freshly minted one and returns the new plaintext exactly once. The previous key remains valid until the replacement write succeeds.

func (*Store) Verify

func (s *Store) Verify(secret string) error

Verify checks secret against the persisted record using prefix lookup and a constant-time digest comparison.

type Verifier

type Verifier interface {
	Verify(secret string) error
}

Verifier validates a presented web access key.

Jump to

Keyboard shortcuts

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