fix(PROJ-64): Session-Invalidation bei Passwort-Change + Datei-Permissions gehärtet

Security-Audit deckte zwei Medium-Findings auf: JWTs blieben bis zu 8h nach
Passwort-Change/-Reset oder Admin-TOTP-Reset gültig (kein Session-Invalidation),
und archivierte Mails/Anhänge wurden mit 0644/0755 statt 0600/0700 geschrieben.

- users.tokens_valid_after (neue Spalte) wird bei SetPassword() und
  InvalidateTokensBefore() gesetzt; ValidateToken() lehnt JWTs mit iat davor ab.
- Admin-TOTP-Reset revoked jetzt aktive Sessions des Zielnutzers.
- Mail-/Attachment-Dateien und ihre Verzeichnisse nur noch für den
  archivmail-Service-Account lesbar.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
sysops
2026-07-03 22:23:27 +02:00
co-authored by Claude Sonnet 5
parent 0ccbd5bafb
commit b286352d07
7 changed files with 96 additions and 9 deletions
+2 -2
View File
@@ -42,11 +42,11 @@ func (s *Store) saveAttachments(ctx context.Context, emailID string, pm *mailpar
}
attPath := s.attachmentPath(hash)
if err := os.MkdirAll(filepath.Dir(attPath), 0o755); err != nil {
if err := os.MkdirAll(filepath.Dir(attPath), 0o700); err != nil {
return fmt.Errorf("storage: attachment mkdir: %w", err)
}
if _, statErr := os.Stat(attPath); os.IsNotExist(statErr) {
if err := os.WriteFile(attPath, toWrite, 0o644); err != nil {
if err := os.WriteFile(attPath, toWrite, 0o600); err != nil {
return fmt.Errorf("storage: attachment write: %w", err)
}
}