Härtung: Login-Drosselung je IP/Konto, Mail-Anhangfehler ohne Retry, doppeltes Upload-Audit

- rate-limit: neuer Scope login (20/15 min, LOGIN_RATE_LIMIT_PER_15_MIN) je IP und
  je Konto; geprüft in verifyIdentityPassword (Login-Seite + Credentials-Provider),
  gedrosselt verhält sich wie Fehlanmeldung (generisch, konstante Laufzeit) – L10a
- mail/worker: MailAttachmentError wie MailNotConfiguredError unrecoverable
  (fremder Mandant/Prüfsumme/Größe ändern sich nicht durch Warten) – L11
- field/uploads: Dokument-Audit nur noch in storeFile (vorher doppelt) – L10a
- Test test-login-rate-limit

Gate 65/65 grün; komplette Suite mit RLS_ENFORCED=true 65/65 grün.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-14 18:59:47 +02:00
co-authored by Claude Opus 5
parent 40c3e8e46b
commit ef2f3f16c6
5 changed files with 79 additions and 12 deletions
+4 -3
View File
@@ -1,5 +1,5 @@
import { UnrecoverableError, Worker, type Job } from "bullmq";
import { deliverMail, markMailFailed, MailNotConfiguredError } from "./deliver";
import { deliverMail, markMailFailed, MailAttachmentError, MailNotConfiguredError } from "./deliver";
import { closeQueues, getConnection, getDeadLetterQueue, getSchedulerQueue } from "./queue";
import { DUE_REMINDER_JOB, MAIL_QUEUE, SCHEDULER_QUEUE, type MailJob } from "./job";
import { closeMailProvider } from "./provider-smtp";
@@ -34,8 +34,9 @@ export function startMailWorker(): Worker<MailJob> {
const { messageId } = await deliverMail(job.data);
return { messageId };
} catch (err) {
if (err instanceof MailNotConfiguredError) {
// Nicht wiederholen — die Konfiguration ändert sich nicht durch Warten.
if (err instanceof MailNotConfiguredError || err instanceof MailAttachmentError) {
// Nicht wiederholen — Konfiguration bzw. ein unzulässiger/fehlender Anhang
// (fremder Mandant, Prüfsumme, Größe) ändern sich nicht durch Warten.
// BullMQ bricht die Retry-Kette bei UnrecoverableError sofort ab.
throw new UnrecoverableError(err.message);
}