cellsecrets

package
v0.0.0-...-043add5 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2026 License: MIT Imports: 10 Imported by: 4 modules, 2 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 cellsecrets provides helpers shared across the cellmodules/ cell modules (accesscore, auditcore, configcore) and cmd/corebundle.

This package is importable by cmd/corebundle (composition root). It contains helpers that both cellmodules/ cell modules and cmd/ need: demo-key rejection, cursor codec construction, HMAC key loading, JWT key set loading, and the pgxpool type assertion.

Index

Constants

View Source
const RealAdapterMode = "real"

RealAdapterMode is the canonical value activating production fail-fast behavior.

Variables

This section is empty.

Functions

func BuildCursorCodec

func BuildCursorCodec(cfg CursorCodecConfig) (*query.CursorCodec, error)

BuildCursorCodec constructs a CursorCodec from already-read primary and previous key strings.

func BuildHMACKey

func BuildHMACKey(cfg HMACKeyConfig) ([]byte, error)

BuildHMACKey loads and validates the HMAC key.

func IsRealMode

func IsRealMode(adapterMode string) bool

IsRealMode reports whether adapterMode activates real-mode guards.

func IsWellKnownDemoKey

func IsWellKnownDemoKey(key []byte) bool

IsWellKnownDemoKey reports whether key matches a shipped public dev default. The comparison uses crypto/subtle.ConstantTimeCompare to avoid timing oracles (startup, not hot-path).

func LoadCellHMACKey

func LoadCellHMACKey(cellEnvPrefix string) string

LoadCellHMACKey reads the HMAC key env var for a specific cell using the per-cell namespace convention (GOCELL_<CELLID>_HMAC_KEY).

func LoadConfigCoreKeyProvider

func LoadConfigCoreKeyProvider() (providerName, masterKey, prevMasterKey string)

LoadConfigCoreKeyProvider reads the configcore-specific KeyProvider configuration:

GOCELL_CONFIGCORE_KEY_PROVIDER
GOCELL_CONFIGCORE_MASTER_KEY
GOCELL_CONFIGCORE_MASTER_KEY_PREVIOUS

func LoadCursorKeys

func LoadCursorKeys(cellEnvPrefix string) (primary, previous string)

LoadCursorKeys reads the cursor HMAC primary and previous keys for a cell.

Env variables read:

GOCELL_<CELLID>_CURSOR_KEY
GOCELL_<CELLID>_CURSOR_PREVIOUS_KEY

func LoadKeySet

func LoadKeySet(adapterMode string, clk clock.Clock) (*auth.KeySet, error)

LoadKeySet returns a KeySet, preferring environment-provided keys. In "real" adapter mode, env keys are required (fail-fast if missing).

func LoadWebhookSourceKeyProvider

func LoadWebhookSourceKeyProvider() (providerName, masterKey, prevMasterKey string)

LoadWebhookSourceKeyProvider reads the KeyProvider configuration for the persistent, encrypted webhook source secret store (#1540). See cellmodules/webhooksource.buildKeyProviderFromName for provider semantics:

GOCELL_WEBHOOK_KEY_PROVIDER        (required in postgres mode: "local-aes" | "vault-transit")
GOCELL_WEBHOOK_MASTER_KEY          (required for local-aes; ignored for vault-transit)
GOCELL_WEBHOOK_MASTER_KEY_PREVIOUS (optional rotation key; local-aes only)

func PgxPoolFromProvider

func PgxPoolFromProvider(pg capability.PGProvider) (*pgxpool.Pool, error)

PgxPoolFromProvider is the single type-assertion site for the capability.PGProvider's any-typed DB() seam. Placed here so all cellmodules/ cell modules and cmd/ reuse it without duplicating the assertion.

cellmodules/cellsecrets is a composition-root layer (like cmd/) so importing adapters/ (pgxpool) is architecturally acceptable.

func RejectDemoKey

func RejectDemoKey(adapterMode, envName string, key []byte) error

RejectDemoKey returns an error in real mode when key matches a well-known demo value.

func ResolveAndRejectDemoKey

func ResolveAndRejectDemoKey(adapterMode, envLabel, primary, devDefault string) ([]byte, error)

ResolveAndRejectDemoKey picks key material from primary (or falls back to devDefault in dev mode), fails fast in real mode when primary is empty, and rejects known-demo key values.

func WellKnownDemoKeys

func WellKnownDemoKeys() []string

WellKnownDemoKeys returns a copy of the demo-key denylist for callers that must enumerate every value (e.g. tests asserting each is rejected in real mode). Returning a clone prevents mutation of the unexported backing slice.

Types

type CursorCodecConfig

type CursorCodecConfig struct {
	AdapterMode string
	EnvName     string
	PrevEnvName string
	Primary     string
	Previous    string
	DevDefault  string
	Label       string
}

CursorCodecConfig encapsulates BuildCursorCodec parameters.

type HMACKeyConfig

type HMACKeyConfig struct {
	AdapterMode string
	EnvName     string
	Primary     string
	DevDefault  string
}

HMACKeyConfig encapsulates BuildHMACKey parameters.

Jump to

Keyboard shortcuts

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