Commit Graph
2 Commits
Author SHA1 Message Date
jwinterm c802f416cd security(auth): harden registration/identity against verified review findings
Adversarial review of the auth/registration surface (findings tracked
privately). Backend half:

- F2: npub-native register no longer binds an npub onto an existing
  wallet row on a seed_fingerprint match alone (unauthenticated account
  takeover). get_or_create_user_by_nostr_pubkey fails closed (409);
  linking an npub goes through the authenticated /auth/nostr/link flow.
  Integration test rewritten to assert the refuse-and-409 contract.
- F3: `all`-mode gate verifies payment is settled (non-consuming) BEFORE
  consuming the single-use invite, so a still-confirming payment can't
  permanently burn the invite. verify_payment_settled split out.
- F4: username availability is pre-checked before any gate token is
  consumed; collisions return 409, not 500 — a taken username no longer
  burns a paid invoice / invite.
- F6: nostr_register now persists the submitted chain keys, so
  receive-by-username and restore self-verification work for npub wallets.
- F10: the pay-to-register not-yet-settled response carries a stable
  PAYMENT_PENDING code so polling clients don't parse a free-text string.

Validated against Postgres: full suite 283 passed / 0 failed.
2026-07-06 04:23:11 -04:00
jwinterm f958aaf0f7 feat: config (fail-closed) + error handling
config.rs (keystone, audited):
- single env reader; validate() FAILS CLOSED on weak/placeholder/missing secrets
  (JWT_SECRET >=32 + non-placeholder, required peppers, PUBLIC_API_URL required
  + url-validated + https-in-prod when Nostr identity on, PoW/admin secrets when
  those features enabled, per-enabled-chain infra secrets hard-fail in prod)
- Nostr-native + feature-flagged; NO telegram/discord/trocador; no dev-fallback keys
- typed sections: auth, identity, secrets(peppers), trusted_proxies, features,
  chains, pow, admin, landing, retention; deployment_mode single|fleet
- secret-bearing structs do not derive Debug; 7 fail-closed validation tests

error.rs: CWE-209 LEAKY/SAFE split (log-private + generic public), error_code
mapping, 5 regression tests.
2026-06-22 07:00:09 -04:00