feat: append-only audit trail for all mutations (P0)
- Database: kanzlai.audit_log table with RLS, append-only policies (no UPDATE/DELETE), indexes for entity, user, and time queries - Backend: AuditService.Log() with context-based tenant/user/IP/UA extraction, wired into all 7 services (case, deadline, appointment, document, note, party, tenant) - API: GET /api/audit-log with entity_type, entity_id, user_id, from/to date, and pagination filters - Frontend: Protokoll tab on case detail page with chronological audit entries, diff preview, and pagination Required by § 50 BRAO and DSGVO Art. 5(2).
This commit is contained in:
22
backend/internal/models/audit_log.go
Normal file
22
backend/internal/models/audit_log.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
type AuditLog struct {
|
||||
ID int64 `db:"id" json:"id"`
|
||||
TenantID uuid.UUID `db:"tenant_id" json:"tenant_id"`
|
||||
UserID *uuid.UUID `db:"user_id" json:"user_id,omitempty"`
|
||||
Action string `db:"action" json:"action"`
|
||||
EntityType string `db:"entity_type" json:"entity_type"`
|
||||
EntityID *uuid.UUID `db:"entity_id" json:"entity_id,omitempty"`
|
||||
OldValues *json.RawMessage `db:"old_values" json:"old_values,omitempty"`
|
||||
NewValues *json.RawMessage `db:"new_values" json:"new_values,omitempty"`
|
||||
IPAddress *string `db:"ip_address" json:"ip_address,omitempty"`
|
||||
UserAgent *string `db:"user_agent" json:"user_agent,omitempty"`
|
||||
CreatedAt time.Time `db:"created_at" json:"created_at"`
|
||||
}
|
||||
Reference in New Issue
Block a user