Search by

filagora / filagora-compliance

zcwilt

Cookie consent, policy versions and privacy requests (export and erasure) for Filagora.

Package info

github.com/filagora/filagora-compliance

pkg:composer/filagora/filagora-compliance

Statistics

Installs: 713

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v0.1.3 2026-11-14 10:33 UTC

This package is auto-updated.

Last update: 2026-11-15 12:52:26 UTC


README

Cookie consent, policy versions and privacy requests (export and erasure) for Filagora, as a Laravel 13 / Filament 5 plugin. Requires filagora/filagora-core. Who may use the screens is answered by core's AccessChecker: install filagora/filagora-entitlements and it is answered from entitlement grants, or bind your own checker. With neither, the screens deny everyone.

The package is at 0.1: the API may change between 0.x minor versions. There is no frontend: it is models, services, events, commands and staff screens, and you build the public forms (cookie banner, privacy request form) over the services.

What it provides

Overview

Cookie consent, policy versions and privacy requests (export and erasure) for Filagora.

Tables

cookie_consent_groups, cookie_consent_cookies, cookie_policy_versions, user_cookie_consents, privacy_policy_versions, user_privacy_policy_acceptances, privacy_requests, privacy_operation_audits, prefixed filagora_ by default. A site that already has them can run php artisan filagora:adopt instead of migrating.

Commands

Command What it does
filagora:compliance:prune {--dry-run} Delete records that are past their retention period, as every installed package defines it.

Events

  • PrivacyReplySent: Staff replied to the person who made a request.
  • PrivacyRequestStatusChanged: A request moved from one status to another.
  • PrivacyRequestSubmitted: A person made a privacy request.

Access

Ability Entitlement key
filagora.compliance.privacy_requests.view filagora.compliance.privacy_requests.view
filagora.compliance.privacy_requests filagora.compliance.privacy_requests
filagora.compliance.erase filagora.compliance.erase
filagora.compliance.cookie_policies filagora.compliance.cookie_policies
filagora.compliance.privacy_policies filagora.compliance.privacy_policies
filagora.compliance.audit filagora.compliance.audit

Using it

  • Tables and models for cookie consent (groups, cookies, policy versions, each user's choice), the privacy policy (versions, each user's acceptance) and privacy requests (with legal hold and an operation audit). They match the site this package was extracted from, so php artisan filagora:adopt accepts that site's existing tables. IP addresses and user agents are stored only as hashes.

  • Abilities filagora.compliance.privacy_requests, .policies and .audit, mapped to entitlement keys in filagora-compliance.gates.

  • Cookie consent (CookieConsent): the enabled groups and cookies to show, the choice a signed-in user made (one row per user, replaced on each save, under the active policy version), and requiresReconsent() when the policy changed since. normalize() merges what was submitted over what the site declares: a required group is always on, a cookie's own choice wins over its group's, a group is on when any of its cookies is. Off when the setting enable_cookie_consent_workflow is off.

  • Privacy policy acceptance (PolicyAcceptance): hasAcknowledgedActivePolicy($user) is cheap enough for a middleware (the active version is cached), accept($user, $ip, $userAgent) records the acceptance, stateFor($user) gives everything a profile page needs. Off when the setting enforce_gdpr is off.

  • Cookie policy versions (CookiePolicyVersions) are numbered by day (2026.10.14.1). With filagora/filagora-cms installed, publishing the page named by the setting cookie_policy_page (a route beginning with /, or a page slug) creates a new version, so users are asked again.

  • The package has no routes, views or JavaScript. Your endpoints are a few lines over the services, for example:

    Route::post('/profile/cookie-consent', fn (Request $r, CookieConsent $consent) =>
        response()->json($consent->save($r->user(), $r->validate(['groups' => 'array', 'cookies' => 'array']), $r->ip(), $r->userAgent())->consent))
        ->middleware('auth');
  • Privacy requests (PrivacyRequests): a person submits an export or erasure request (or rectification, restriction, objection, which staff handle by hand); staff review, hold, reply, reject, or fulfil it. fulfilExport() writes one JSON file with a section for the user and one for every PrivacyContributor any package or your application registered with core's PrivacyContributorRegistry; fulfilErasure() has each contributor erase its data and then your UserAnonymizer replaces who the user is, all in one transaction. A request on legal hold cannot be fulfilled. Every staff action is written to the operation audit, and the requester (and the address in the dsar_request_email setting) are emailed by events you can replace: set mail.enabled to false and listen to PrivacyRequestSubmitted, PrivacyRequestStatusChanged and PrivacyReplySent yourself. The mail's links are named routes of yours under routes in the config (a signed download route for exports, the page where a person sees their requests); any you leave empty is left out.

  • What erasure covers is up to what registers. Register a contributor for your own tables (app(PrivacyContributorRegistry::class)->register(...)) and bind your own UserAnonymizer for user columns the default does not know (it blanks name and email, empties the verification date and makes the password unusable).

  • Retention: php artisan filagora:compliance:prune (scheduled daily at 02:15; --dry-run reports without deleting) runs every RetentionRule registered with core's RetentionRuleRegistry, so each package says what it keeps and for how long. This package's rule deletes settled privacy requests after the windows in retention.privacy_requests (never one on legal hold) and removes export files 30 days after they were made. A rule that fails is reported, mailed to dsar_request_email, and does not stop the others.

  • Filament screens (add FilagoraCompliancePlugin::make() to your panel), each behind its own ability, mapped to keys in filagora-compliance.gates (entitlement keys when entitlements is installed): privacy requests (.privacy_requests.view to look, .privacy_requests to act, .erase to erase a person or delete a request), cookie groups and cookie policy versions (.cookie_policies), privacy policy versions (.privacy_policies) and the operation audit (.audit). A request's page offers every step of its handling; the privacy KPIs (kpis in the config) can sit on your dashboard through PrivacyKpiOverview.

Requirements

PHP 8.4, Laravel 13 and Filament 5. Tested against MariaDB 11.4. Requires filagora/filagora-core.

Install

composer require filagora/filagora-compliance filagora/filagora-entitlements   # entitlements is optional
php artisan migrate
php artisan filagora:entitlements:sync   # with entitlements: creates the ability keys
->plugin(\Filagora\Compliance\FilagoraCompliancePlugin::make())

Then set the dsar_request_email setting (who is told about new requests), schedule your application's schedule:run (the daily prune is registered by the package), and read config/filagora-compliance.php for the links in the mail, where exports are written and the retention windows. To start from a database that already holds these tables, run php artisan filagora:adopt instead of migrate.

Configuration

config/filagora-compliance.php is merged with the host's copy, so list only what differs. Publish it with php artisan vendor:publish --tag=filagora-compliance-config.

Extending

Extend through documented contracts, events and registries. Anything not documented is @internal.

Testing

composer test

Tests run against a real MariaDB, never SQLite, so engine behaviour (FULLTEXT, ONLY_FULL_GROUP_BY, collation) matches production. Host and credentials come from your environment; the database is always named testing, never your development one.

Local development (DDEV)

.ddev/ is included. ddev start creates both db and testing (run ddev restart once if testing is missing), then ddev exec vendor/bin/pest.

Licence

MIT. See LICENSE.