Quick overview
This workflow logs append-only audit events to a Supabase Postgres table with database-enforced sequencing and hash chaining, then verifies the chain integrity on demand or on a schedule, with an optional test form that confirms UPDATE and DELETE operations are blocked.
How it works
- Runs either manually to generate demo events, on a schedule to verify integrity, or when called from another workflow via Execute Workflow to receive an audit event.
- For the demo path, creates five fictional events, hashes each original payload with SHA-256, and prepares the audit fields (workflow and execution context, actor, reason, and details).
- Validates incoming audit events, enforcing required fields and allowed values, normalizing optional fields, and deriving a correlation ID when one is not provided.
- Inserts the validated event into the Supabase Postgres audit_log table and returns the assigned sequence number, timestamp, and record hash.
- For demo runs, queries Supabase to recompute and verify the full hash chain and reports whether the chain is intact or identifies the first broken sequence.
- For optional functional tests, accepts a confirmation form submission and attempts an UPDATE and DELETE in Supabase, reporting PASS when the database rejects both operations.
Setup
- Create a Supabase project and run the provided SQL in the Supabase SQL Editor to create the audit_log table plus triggers and verification functions.
- Create a Postgres credential in n8n using your Supabase connection details (use the Session Pooler string if needed) and select it in the nodes that write, verify, and run the optional UPDATE/DELETE tests.
- If you use this as a shared logger, call it from your other workflows with an Execute Workflow node and pass action, status, and the source workflow/execution fields (and any optional actor, reason, details, correlation_id, or payload_hash).
- Set the integrity-check schedule interval to your needs and, before production use, remove the optional functional test section since it intentionally tries to update and delete audit records.