Prompt
I'm building a product that needs audit trails for consent. What should I use?
Latest observation
For consent audit trails, you usually want a combination of:
-
An append-only event log
Record each consent-related action as an immutable event:- consent given
- consent withdrawn
- scope changed
- timestamp
- user identity / subject identifier
- source/channel
- version of consent text shown
- device/IP/location if appropriate
- actor who recorded it
-
A tamper-evident storage layer
Use storage that prevents silent edits, such as:- append-only database tables
- write-once storage
- log systems with cryptographic hashing
- cloud audit log services
-
Versioned consent documents
Store the exact text/policy shown at the time, with a version ID and hash. That way you can prove what the user actually agreed to. -
Strong identity and timestamps
Capture:- authenticated user ID
- UTC timestamp
- request/session ID
- signature or proof of action if needed
-
Access controls and retention policies
Make sure only authorized services can write to the log, and define how long records must be retained for compliance.
If you want a concrete stack, common choices are:
- PostgreSQL with an append-only
consent_eventstable + immutable policy version table - AWS: CloudTrail/CloudWatch + S3 Object Lock + DynamoDB/Postgres
- Azure: Azure Monitor + immutable blob storage
- GCP: Cloud Audit Logs + BigQuery/Postgres
- For higher integrity: add hash chaining or a digital signature per event
A practical pattern is:
consent_policiestable: versioned policy contentconsent_eventstable: every grant/revoke as a new row- API writes events only, never updates past events
- compute
previous_hash/event_hashto detect tampering
If you tell me your stack (cloud, database, compliance needs like GDPR/HIPAA, and whether you need legal-grade evidence), I can recommend the best specific setup.