settings

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package settings holds the operational config every real product needs — project name, timezone, managed API keys, and the session-signing secret — persisted as a single JSON file (atomic rewrite), separate from event data.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIKey

type APIKey struct {
	ID      string    `json:"id"`
	Name    string    `json:"name"`
	Key     string    `json:"key"`
	Created time.Time `json:"created"`
}

APIKey is a managed ingestion key (in addition to any env-configured key).

type Account

type Account struct {
	Username string `json:"username"`
	Hash     string `json:"hash"` // iterated HMAC-SHA256 of the password
	Salt     string `json:"salt"`
}

Account is the single operator login (in-app, self-serve — no env required).

type Store

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

Store is the concurrency-safe, persisted settings.

func Open

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

func (*Store) AddKey

func (s *Store) AddKey(name string) (APIKey, error)

func (*Store) CheckPassword

func (s *Store) CheckPassword(password string) bool

CheckPassword verifies a password against the stored hash (constant-time).

func (*Store) HasPassword

func (s *Store) HasPassword() bool

func (*Store) Keys

func (s *Store) Keys() []APIKey

func (*Store) ProjectName

func (s *Store) ProjectName() string

func (*Store) RetainDays

func (s *Store) RetainDays() int

func (*Store) RevokeKey

func (s *Store) RevokeKey(id string) error

func (*Store) RotateSecret

func (s *Store) RotateSecret() error

RotateSecret generates a new session-signing secret, invalidating every existing session cookie ("sign out everywhere").

func (*Store) Secret

func (s *Store) Secret() string

func (*Store) SetAccount

func (s *Store) SetAccount(username, password string) error

SetAccount sets the operator username + password (hashed). Empty username keeps the existing one.

func (*Store) SetRetainDays

func (s *Store) SetRetainDays(days int) error

func (*Store) Timezone

func (s *Store) Timezone() string

func (*Store) UpdateProject

func (s *Store) UpdateProject(name, tz string) error

func (*Store) Username

func (s *Store) Username() string

func (*Store) ValidKey

func (s *Store) ValidKey(key string) bool

ValidKey reports whether key matches any managed key, compared in constant time (and without early-exit) to avoid leaking which/how-many keys exist via timing.

Jump to

Keyboard shortcuts

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