feat(invitations): hardening — configurable expiry, 2^40 short codes, sweep (task 1.5, INV-04/06) #60
No reviewers
Labels
No labels
epic
phase-0
phase-1
phase-2
phase-3
phase-4
phase-5
phase-6
phase-7
phase-8
phase-9
priority/P0
priority/P1
priority/P2
type/backend
type/client
type/docs
type/ops
type/security
type/spike
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
primatekuntech/failsulit!60
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/1.5-invitation-hardening"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #20 (task 1.5)
INV-04 — configurable expiry, single source
InvitationsOptions.ExpiryDays(default 7) bound fromInvitations:ExpiryDays— replaces both hardcodedAddDays(7)sites (CreateInvitation, CreateAdminInvitation); config change takes effect without code changeINV-06 — short-code entropy + brute-force defense
invite-code-lookuprate-limit partition (20/min prod, 100/min in Testing so the brute-force test proves it: 1000 wrong guesses → 429)Sweep job (P1)
InvitationExpirySweepService: hourly BackgroundService flipping stale Pending → Expired (startup deferred 5 min); publicSweepOnceAsync; materialize-then-filter per house SQLite-compat styleTDD evidence
7 tests written first — RED ×6 confirmed, then implemented to green.
Suite: 774 total / 0 failed / 39 skipped (Release). Coverage gate: 81.77% ≥ 80%
INV-04 — expiry configurable (Invitations:ExpiryDays, default 7): - InvitationsOptions bound from config; replaces BOTH hardcoded AddDays(7) sites (CreateInvitation + CreateAdminInvitation) — config changes take effect without code changes - expired invites now read back as 410 Gone (was 404) on the public token/code preview endpoints so clients can say 'lapsed' vs 'unknown'; lazy flip at acceptance read retained INV-06 — short codes ≥ 2^40 guessing space: - suffix 4 → 8 chars from the 32-symbol alphabet (32^8 = 2^40; the tenant prefix is guessable and doesn't count); structural assertion in tests; 6-char fallback loop removed (space no longer needs it) - code-lookup endpoint gets its own tighter rate-limit partition ('invite-code-lookup', 20/min prod — same as auth; 100/min in tests so the brute-force test can prove it: 1000 wrong guesses → 429) Sweep job (P1): - InvitationExpirySweepService: hourly BackgroundService (startup deferred 5 min) flipping stale Pending → Expired; public SweepOnceAsync for tests; complements the lazy flip for rows nobody reads; materialize-then-filter per house SQLite-compat style TDD: 7 new tests written first (RED ×6 confirmed), then implemented. Suite 774 total / 0 failed / 39 skipped (Release); coverage gate 81.77% >= 80% floor.