spatie/laravel-ciphersweet
Laravel wrapper for Paragonie CipherSweet that adds searchable field-level encryption to Eloquent models. Encrypt/decrypt sensitive attributes and generate blind indexes so you can query encrypted data securely without exposing readable values in your database.
ciphersweet PHP extension), making it adaptable to most Laravel deployments.config/ciphersweet.php) and integrates with Laravel’s Service Container and Eloquent.ciphersweet PHP extension (not bundled with PHP), which may need PECL installation or Docker setup.encrypted_* columns) could complicate future migrations.GROUP BY, JOIN) that can’t use CipherSweet’s searchable fields?pgcrypto/AES functions.CipherSweet for unit tests).passwords, credit_cards, health_records) for encryption candidates.WHERE email LIKE '%@gmail.com').user.bio) first to validate performance.encrypted_* columns via Laravel migrations.CipherSweet::encrypt() macros to Eloquent models.config/ciphersweet.php.artisan cipher:sweet:rotate).ciphersweet extension (PHP 8.0+). Docker example provided in README.DB::select() with CipherSweet’s query methods.| Phase | Tasks | Dependencies |
|---|---|---|
| Prep | Install ciphersweet extension, configure Laravel. |
PHP/Docker setup. |
| Pilot | Encrypt 1–2 non-critical fields; test queries. | Database backup. |
| Core Rollout | Encrypt PII fields; update models/queries. | Pilot validation. |
| Key Management | Set up KMS/Vault; test key rotation. | Encrypted data in production. |
| Monitoring | Log decryption failures; alert on key issues. | Full deployment. |
artisan cipher:sweet:rotate.CipherSweet\Exceptions\DecryptionFailed events.DB::enableQueryLog() to inspect rewritten queries.SHOW PROCESSLIST (MySQL) or pg_stat_activity (PostgreSQL).env) requires synchronization.| Risk | Impact | Mitigation Strategy |
|---|---|---|
| Key Loss/Corruption | Permanent data loss. | Automated backups of keys; KMS snapshots. |
| Database Corruption | Encrypted data becomes unreadable. | Regular backups; test restore procedures. |
| Query Rewriting Errors | Broken searches/filters. | Unit tests for encrypted queries. |
| Extension Misconfiguration | Decryption failures. | CI checks for ciphersweet extension. |
| Key Rotation Failures | Data becomes unreadable. | Dry-run rotations; monitor logs. |
How can I help you explore Laravel packages today?