Feat: Updating the Privacy Providers, moving them into the appropriate Modules, Updating Privacy views
This commit is contained in:
+30
-7
@@ -124,17 +124,40 @@ from the record staff (or the person themselves) look up.
|
||||
|
||||
## Providers shipped in core
|
||||
|
||||
| Provider | `name()` | Covers | Customer-scope | User-scope |
|
||||
|---|---|---|---|---|
|
||||
| `CustomerDataProvider` | `customer` | `lunar_customers`, and separately the `User`'s own name/email | Erases the account's own fields only | Erases that User's name/email only, and detaches them from every linked Customer |
|
||||
| `AddressDataProvider` | `addresses` | `lunar_addresses` | Erased (deleted outright) | Skipped — belongs to a Customer, not an individual |
|
||||
| `OrderDataProvider` | `orders` | `lunar_orders`, `lunar_order_addresses` | **Pseudonymized, not erased** — see below | Skipped — belongs to a Customer, not an individual |
|
||||
| `CartDataProvider` | `carts` | `lunar_cart_addresses` | Erased | Skipped — belongs to a Customer, not an individual |
|
||||
| `ReviewDataProvider` | `reviews` | `product_reviews` | Skipped — authored by an individual, not a business account | Pseudonymized by matching `reviewer_email`; rating/title/body text kept |
|
||||
| Provider | `name()` | Lives in | Covers | Customer-scope | User-scope |
|
||||
|---|---|---|---|---|---|
|
||||
| `ActivityLogDataProvider` | `activity_log` | `Modules\Core\Logging\Privacy` | `activity_log` (Spatie) for subject types `Customer`/`Address`/`CartAddress`/`OrderAddress`/`Transaction` | **Pseudonymized** — `properties` redacted, who/what/when metadata kept | Skipped — `causer_id` is an actor reference, not PII content; see below |
|
||||
| `CustomerDataProvider` | `customer` | `Modules\Core\Customer\Privacy` | `lunar_customers`, and separately the `User`'s own name/email/OTP fields | Erases the account's own fields only | Erases that User's name/email/OTP fields only, and detaches them from every linked Customer |
|
||||
| `AddressDataProvider` | `addresses` | `Modules\Core\Customer\Privacy` | `lunar_addresses` | Erased (deleted outright) | Skipped — belongs to a Customer, not an individual |
|
||||
| `OrderDataProvider` | `orders` | `Modules\Core\Order\Privacy` | `lunar_orders`, `lunar_order_addresses`, and their `meta` (`terms_accepted*`, `payment_method`, `box_now_locker`) | **Pseudonymized, not erased** — see below | Skipped — belongs to a Customer, not an individual |
|
||||
| `CartDataProvider` | `carts` | `Modules\Core\Cart\Privacy` | `lunar_cart_addresses`, and `lunar_carts.meta` (`recovery_consent*`, `payment_method`, `checkout_fingerprint`) | Erased | Skipped — belongs to a Customer, not an individual |
|
||||
| `ReviewDataProvider` | `reviews` | `Modules\Core\Review\Privacy` | `product_reviews` | Skipped — authored by an individual, not a business account | Pseudonymized by matching `reviewer_email`; rating/title/body text kept |
|
||||
| `PaymentDataProvider` | `payments` | `Modules\Core\Payment\Privacy` | `lunar_transactions` (`card_type`/`last_four`), `stripe_payment_intents` | **Pseudonymized** — card metadata cleared, correlation rows deleted, amounts/statuses kept | Skipped — belongs to Customer-owned orders, not individual users |
|
||||
| `UserSessionDataProvider` | `sessions` | `Modules\Core\Auth\Privacy` | `user_sessions` (`ip_address`, `user_agent`) | Skipped — belongs to an individual User, not a business account | Erased (deleted outright) |
|
||||
|
||||
`CustomerDataProvider` is the one provider that implements both scopes meaningfully, and keeps
|
||||
them from touching each other — see the class docblock for the full reasoning.
|
||||
|
||||
### `activity_log` is redacted by subject, never by causer
|
||||
|
||||
`Modules\Core\Logging\ActivityLogService` (plus several Lunar models' own native `use
|
||||
LogsActivity` — `Customer`, `CartAddress`, `OrderAddress`, `Transaction`) durably retains a full
|
||||
snapshot of whatever it logged in `properties`, completely independent of the real row it
|
||||
describes — erasing/pseudonymizing a `Customer`/`Address`/`Order`/etc. elsewhere does nothing to
|
||||
this table on its own. `ActivityLogDataProvider::eraseForCustomer()` redacts `properties` on
|
||||
every row whose **subject** (not causer) resolves back to that customer, across all five
|
||||
PII-bearing subject types.
|
||||
|
||||
It deliberately never touches `causer_id` — the causer is "who performed this action," not PII
|
||||
content, and erasing it would defeat the audit trail's own purpose. `eraseForUser()` is
|
||||
therefore a no-op: a `User` appears in this table only as a causer, never as subject content, so
|
||||
there's nothing to redact from the User side alone.
|
||||
|
||||
**Ordering dependency**: `ActivityLogDataProvider` must run *before* `AddressDataProvider` in
|
||||
`config('core.privacy.providers')` — it resolves which `activity_log` rows are keyed by an
|
||||
`Address` id while those Address rows still exist; `AddressDataProvider` then hard-deletes them.
|
||||
Reversing the order would make matching those rows impossible once the addresses are gone.
|
||||
|
||||
**`ReviewDataProvider` needs review.** It moved from Customer-scope to User-scope on the
|
||||
reasoning that authorship is a personal attribute, not a business-account attribute — but this
|
||||
hasn't been fully validated against how reviews are actually attributed in this codebase. The
|
||||
|
||||
Reference in New Issue
Block a user