settings

package
v1.786.131 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package settings is the per-org, per-product configuration plane for the unified Hanzo Cloud binary — the /v1/settings/:product surface that lets an org read and edit a product's configuration, backed by a durable per-tenant store with KMS custody for any secret-typed field.

ONE settings engine, EVERY product. The console drives all ~130 products' Settings tab through this single surface (product id → :product). The config SCHEMA is a small, fixed, honest default set (fields that are genuinely stored, org-scoped, and readable by a product's own backend via the in-process seam) — merged with the org's persisted overrides. There is no per-product bespoke server code; a product is just a (org, product) key.

TENANT ISOLATION (what Red will attack). The org is ALWAYS principal.Tenant — the validated IAM owner claim (HIP-0026), never a client-supplied header, query param, or body field. Every store query binds `WHERE org=? AND product=?`; every KMS secret is keyed /orgs/{org}/settings/{product}/{key}. An org can therefore read or write ONLY its own product config. The product path segment is strictly slug-validated at the boundary so it can never smuggle path structure into the KMS key or the store key.

SECRET CUSTODY. A secret-typed field's VALUE lives ONLY in KMS (sealed, AES-256-GCM envelope); the store keeps only a non-secret marker that the secret is set. A GET never returns a secret value (masked). If KMS is not Ready, a write that includes a secret field fails closed (503) — a secret is NEVER written to SQLite in plaintext.

Surface (subsystem "settings", prefix /v1/settings; /v1 only):

GET /v1/settings/:product   the merged config doc (secrets masked)  -> settingsView
PUT /v1/settings/:product   persist config overrides                -> settingsView

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Config

func Config(ctx context.Context, org, product string) (map[string]string, bool)

Config returns an org's persisted NON-secret settings values for a product (the merged view of defaults + overrides), for a product's own backend to consume. Fails closed (nil) when unmounted. Secret values are NOT returned here — a consumer fetches those from KMS by the documented path.

func Mount

func Mount(app *zip.App, deps cloud.Deps) error

Mount wires /v1/settings/* onto app.

func Shutdown

func Shutdown(_ context.Context) error

Shutdown closes the store. Idempotent.

Types

type Record

type Record struct {
	Org       string
	Product   string
	Doc       string // opaque JSON config document (non-secret values + secret markers)
	UpdatedAt int64
}

Record is one org's persisted settings for one product.

type Store

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

Store is the settings metastore over one SQLite file. MaxOpenConns(1) serializes writes against the file lock (same discipline as eval/integrations).

func (*Store) Close

func (s *Store) Close() error

Close closes the underlying database.

func (*Store) Get

func (s *Store) Get(ctx context.Context, org, product string) (Record, bool, error)

Get returns the persisted record for (org, product). found=false (nil error) when there is no row. Tenant isolation: the WHERE always binds org AND product.

func (*Store) Put

func (s *Store) Put(ctx context.Context, org, product, doc string, updatedAt int64) error

Put upserts the config document for (org, product). The org is stamped from the validated principal by the caller; this never trusts a client-supplied org.

Jump to

Keyboard shortcuts

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