feat: store Outpost credentials as digests and rate limit public endpoints (auth M4)

Credentials
- pairing codes and Outpost upload tokens are stored only as SHA-256 digests; the
  token is minted at claim (256-bit OsRng) and returned once
- the old clear-text wormhole_tokens table is migrated in place and dropped with
  secure_delete; active tokens keep working with a fresh lifetime
- admin rotate (with grace window) and revoke endpoints, audited; a revoked
  Outpost is refused on its next request
- optional end date for the shared admin token (TESSERA_ADMIN_TOKEN_EXPIRES)

Limits
- governor per-source limits for emergency login, pairing claim and SSO
  start/callback; X-Forwarded-For only from TESSERA_TRUSTED_PROXIES; IPv6 by /64
- at most two concurrent Argon2 verifications, refused immediately when busy
- denials audited at most once a minute per source
- the mTLS listener now supplies the peer address to handlers

Existing hubs: rotate every Outpost token after upgrading; old database copies
still contain the clear-text tokens.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-14 14:06:18 +07:00
parent 618681fa7f
commit 54abd02250
22 changed files with 1376 additions and 164 deletions

View File

@@ -422,7 +422,7 @@ fn authenticate_outpost(state: &HubState, headers: &HeaderMap) -> Result<Uuid, S
let token = upload_token(state, headers)?;
let id = state
.db
.upload_token_outpost(token)
.upload_token_outpost(token, chrono::Utc::now().timestamp())
.map_err(internal)?
.ok_or(StatusCode::UNAUTHORIZED)?;
let id = Uuid::parse_str(&id).map_err(internal)?;