Search by

jeffersongoncalves / laravel-gdpr-audit-log

jeffersongoncalves

GDPR accountability for Laravel (Art. 5(2)): tamper-evident, hash-chained log of who viewed, changed, exported or erased personal data.

1.0.0 2026-11-17 12:09 UTC

This package is auto-updated.

Last update: 2026-11-17 12:10:03 UTC


README

Laravel GDPR Audit Log

Latest Version on Packagist Tests Total Downloads

The EU General Data Protection Regulation (GDPR) makes the controller responsible for, and able to demonstrate, compliance (accountability, Art. 5(2)), and asks for measures that ensure the security of processing (Art. 32). This package keeps an audit trail of who viewed, changed, exported or anonymized personal data, built on laravel-gdpr's #[PersonalData] declarations.

  • Column names, never values: the log itself doesn't copy the data it protects.
  • Append-only and hash-chained: each entry carries an HMAC of the previous one. gdpr:audit-verify tells you if an entry was altered, removed from the middle or inserted.
  • Automatic where Eloquent can see it: changes to personal data columns, deletions, and every anonymization (DSAR erasure, retention).

This package gives you tooling. It does not make you compliant on its own.

Installation

composer require jeffersongoncalves/laravel-gdpr-audit-log
php artisan vendor:publish --tag="gdpr-audit-log-migrations"
php artisan migrate

Set GDPR_HASH_KEY (see laravel-gdpr). The chain falls back to APP_KEY, and rotating the key makes older entries fail verification.

Usage

Add the trait to the models that hold personal data:

use JeffersonGoncalves\GdprAuditLog\Concerns\AuditsPersonalData;

#[PersonalData('email', anonymize: AnonymizeStrategy::Hash)]
class Customer extends Model implements HasPersonalData
{
    use AuditsPersonalData;
    use InteractsWithPersonalData;
}
  • Updating a declared column logs updated with the column names. Other columns are ignored.
  • Deleting the model logs deleted.
  • anonymizePersonalData(), called directly, by laravel-gdpr-dsar or by laravel-gdpr-retention, logs anonymized. That save also logs updated first.

Eloquent can't tell when data is read, so log access where you show it:

$customer->auditAccess('Support ticket #42');            // all declared columns
$customer->auditAccess('Billing', ['email']);

GdprAuditLog::record('exported', $customer, ['email'], 'Answer a DSAR', ['ticket' => 42]);

The actor is the authenticated user unless you pass actor:. The IP address and user agent of the request are stored too (store_request). They are personal data, so they stay out of the hash chain and can be anonymized without breaking it.

Verifying

php artisan gdpr:audit-verify
// routes/console.php
Schedule::command('gdpr:audit-verify')->daily();

The oldest entry you kept is trusted as the start of the chain, so deleting old entries from the start keeps the rest verifiable. A gap in the middle does not.

Testing

composer test

Changelog

See CHANGELOG.

License

The MIT License (MIT). See License File.