appconfig

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2026 License: Apache-2.0, MIT Imports: 20 Imported by: 0

Documentation

Overview

Package appconfig serves public and admin configuration endpoints.

Package appconfig holds admin-editable application settings (branding, sign-up policy, session lifetimes, email toggles) stored in the database and overlaid on internal/config env defaults.

Index

Constants

View Source
const ModuleName = "appconfig"

ModuleName identifies the appconfig module in the registry.

Variables

This section is empty.

Functions

func CIMDAllowlist

func CIMDAllowlist(values map[string]string) []string

CIMDAllowlist reads the operator-managed CIMD URL allowlist from the merged values (JSON array; default deny when unset).

func EnvDefaults

func EnvDefaults(cfg *config.Config) map[string]string

EnvDefaults maps the koanf Mailer section onto the appconfig keys as the env layer of the defaults fold.

Types

type MailSender

type MailSender interface {
	EnqueueEmail(ctx context.Context, msg mailer.Message) error
}

MailSender queues transactional email; internal/jobs implements it.

type Module

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

Module mounts the configuration endpoints.

func New

func New(mailer MailSender, opts ...Option) *Module

New builds the module. A nil mailer leaves the test-email route unmounted (fail closed); the config CRUD needs WithStore.

func (*Module) APIRoutes

func (m *Module) APIRoutes(r chi.Router)

APIRoutes mounts the configuration endpoints relative to /api.

func (*Module) MergedValues

func (m *Module) MergedValues(ctx context.Context) (map[string]string, error)

MergedValues folds env defaults with stored overrides — the cross-module read path (the registry wires the CIMD allowlist from it).

func (*Module) Name

func (*Module) Name() string

Name identifies the module.

func (*Module) WithCipher

func (m *Module) WithCipher(cipher *crypto.Cipher) *Module

WithCipher wires the seal for sensitive settings; without one the module rejects writes to sensitive keys and returns stored ciphertext untouched on reads (fail closed).

func (*Module) WithEnvDefaults

func (m *Module) WithEnvDefaults(defaults map[string]string) *Module

WithEnvDefaults seeds the env-backed defaults (MAILER_* values from the koanf config). Catalog defaults stay the bottom layer; DB overrides stay the top.

func (*Module) WithStore

func (m *Module) WithStore(store Store) *Module

WithStore wires the settings persistence; without it only test-email mounts.

type Option

type Option func(*Module)

Option configures the appconfig module at construction.

func WithGuard

func WithGuard(guard kernel.Guard) Option

WithGuard protects the admin routes; without one nothing admin-facing mounts.

type PostgresStore

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

PostgresStore persists overrides in public.app_config.

func NewPostgresStore

func NewPostgresStore(store datastore.Store) *PostgresStore

NewPostgresStore builds the production config store. The store supplies both the read/write executor and transactions.

func (*PostgresStore) Delete

func (s *PostgresStore) Delete(ctx context.Context, keys []string) error

Delete removes the rows for the given keys; missing keys are not an error.

func (*PostgresStore) List

func (s *PostgresStore) List(ctx context.Context) (map[string]string, error)

List returns every stored override.

func (*PostgresStore) Upsert

func (s *PostgresStore) Upsert(ctx context.Context, values map[string]string) error

Upsert writes the given keys in one transaction.

type Store

type Store interface {
	List(ctx context.Context) (map[string]string, error)
	Upsert(ctx context.Context, values map[string]string) error
	// Delete removes rows by key; clearing a sensitive setting must
	// delete its row because the enc: check rejects empty values.
	Delete(ctx context.Context, keys []string) error
}

Store persists configuration overrides. Defaults live in env-backed config; rows here win.

Jump to

Keyboard shortcuts

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