Replies: 2 comments 3 replies
-
I think this is a problem that needs to be solved for each application specifically. If the framework were to provide a tool, it would need to be very flexible and customisable to support many different scenarios. The framework doesn't know how you've used encryption on your models, so it wouldn't be able to reliably re-encrypt everything safely. There would always be the risk of it missing some encrypted values, or corrupting encrypted values if they are stored in unique formats. I think it's safer to implement your own Artisan command, as you know your data and what would need to be re-encrypted. |
Beta Was this translation helpful? Give feedback.
-
I got inspired and needed a weekend project. The following is the product of that: https://packagist.org/packages/henzeb/laravel-encrypted-data-rotator Would be nice if someone were to test this out, see what's missing, note some potential bugs or other issues. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Currently, when you rotate keys, the data itself isn't rotated but the keys are. New Data gets stored with the new key, and old data expects old keys. The implemented code currently tries to decrypt through the old keys in a loop but you end up with a collection of keys. This partially defeats the purpose of key rotation. Add support to re-encrypt data natively. Ideally it could be a command that dispatches a batch job that iterates through various models that contain the encrypted casting so that old keys can be disposed of.
Beta Was this translation helpful? Give feedback.
All reactions