Compound · stateful · on AlchemyBridge

A credentials and token-authentication service, with state. Two APIs (mTLS management + auth), opaque server-side tokens, multi-engine schema — all from config + rules, without a line of bespoke code.

3consumption scenarios: isolated · local verification · embedded (.nap)
3delegated-verification variants — no network on the traffic path
5DB engines (native SQLite + Postgres/MySQL/SQL Server/Oracle)
46green E2E asserts (base + variants + embedded)
0lines of bespoke code

Two instances, two interfaces

Management · /admin/*
HTTPS + mTLS · :9443
⇄
Native in-process SQLite
clients · tokens (shared)
⇄
Auth · /auth/*
public HTTP/S · :8080

One listener per process → two instances sharing the SAME database (busy_timeout + WAL). Management behind mTLS: only a valid client certificate administers. Token issuance stays on the public surface.

The auth contract

# /auth/token — contrato del cliente { "client_id": "acme-...", "secret_key": "..." } // o username+password // → { "access_token": "opaco", "token_type": "Bearer", "expires_in": 3600 }

Dual model: client_id+secret_key or username+password. The token is OPAQUE (uuid), stored hashed (sha256) with its expiry; the secret with password_hash (bcrypt). Neither the clear token nor the clear secret is persisted.

The operations (by rules)

Management

create · list · get · update (enable/disable) · delete · rotate · revoke-tokens

Auth

opaque token (200/401) · introspect (RFC 7662) · token/signed (JWT EdDSA) · token/pairwise (JWT HS256 + @hkdf) · voucher (JWE A256GCM)

Rotate

regenerates the secret and returns it; the old one stops working

Revoke

UPDATE revoked_at → forces renegotiation

How a component consumes you — the 3 scenarios

1 · ISOLATED for everything
issuance and validation over the network (introspect per request) — instant revocation
2 · Remote issuance + LOCAL verification
the consumer validates without the network — Tessera off the traffic path
3 · FULLY EMBEDDED (.nap)
in-process issuance + validation, zero IPC — ~42% more issuance throughput (lab)

All three are deployment configuration, not code, and all three are E2E-tested. In scenario 3 the signed .nap package travels WHOLE: the host mounts it with packages:, its endpoints serve the extracted rules and the local DSN satisfies the manifest's logical connection. Management (mTLS) is not embedded: it runs separately over the same DB only when administration is needed.

Delegated verification — 3 variants, no network on the traffic path

1 · Symmetric pairwise

JWT HS256 signed with a working key derived via @hkdf(root, pair, epoch) — the root is never used directly; rotating the epoch = rotating parametry. HMAC ~µs: the cheapest option. Only between infrastructure you own.

2 · Delegation voucher

The token stays OPAQUE; Tessera hands over the validity material encrypted (JWE A256GCM) and the delegate persists it in its context (sql backend): it validates locally, survives restarts and a downed Tessera — one @send only on the first miss.

3 · Asymmetric (cached public key)

JWT EdDSA: Tessera signs with its private key (never leaves); each delegate verifies with the cached PUBLIC key — the delegated party cannot forge. One key for everyone; rotation via kid/JWKS.

Reusable templates

require_auth · require_auth_pairwise · require_auth_voucher — copied in front of any consumer's business logic; denial (code and payload) config-driven, never hardcoded.

Security by design

Redaction by default

@DbList strips the sensitive columns declared in config (clients:[secret_hash]) — the list never leaks hashes. The implementer decides.

Hashing

secret → bcrypt (password_hash); token → sha256 (hash_hex). Verified with password_verify.

mTLS on management

the internal API requires a client certificate (require_mtls); auth stays public.

No log leaks

secret/token/hashes masked; metadata logged, never sensitive material.

Zero bespoke code

All from config + transformation rules over existing directives: @uuid, @password_hash/@password_verify, @hash_hex, @now_unix, @Sum, and the DB ones @DbFindRow/@DbInsertRow/@DbUpdateRow/@DbDeleteRow/@DbList. What was added to the engine —generic and reusable— was @DbList with redaction, the native in-process SQLite driver and, with the delegated variants, HS256 in @jose_sign/@jose_verify and field-vs-field conditions in When (%ref resolution on the right-hand side).

Persistence — one schema, five engines

Native in-process SQLite for testing (self-contained; also enables persistent contexts without a plugin). Per-engine schema scripts; clean clients/tokens tables.

SQLite (native in-process)PostgreSQLMySQL/MariaDBSQL ServerOracle