New in Laravel 11 - Encryption Key Rotation

preview_player
Показать описание
If you change your application's encryption key, all authenticated user sessions will be logged out of your application. This is because every cookie, including session cookies, are encrypted by Laravel. In addition, it will no longer be possible to decrypt any data that was encrypted with your previous encryption key.

To mitigate this issue, Laravel allows you to list your previous encryption keys in your application's APP_PREVIOUS_KEYS environment variable. This variable may contain a comma-delimited list of all of your previous encryption keys.

When you set this environment variable, Laravel will always use the "current" encryption key when encrypting values. However, when decrypting values, Laravel will first try the current key, and if decryption fails using the current key, Laravel will try all previous keys until one of the keys is able to decrypt the value.

This approach to graceful decryption allows users to keep using your application uninterrupted even if your encryption key is rotated.

=== Important Links ===

Fonts, extensions I use, and Support Laratips links:

=== Offer ===

GET ONE MONTH OF FREE CLOUDWAYS HOSTING

=== Video Related Links ===

=== Other Videos ===

What's New In Laravel 11 Playlist

What's New In Laravel 10 Playlist

What's New In Laravel 9 Playlist

What's New In Laravel 8 Playlist

Laravel Package Development Playlist

Password Validation In Laravel with at least one Letters, Numbers, Upper and Lowercase or Symbols:

Multiple Apis With ForwardsCalls Trait And Code Refactoring Tip - Laravel Hidden Feature:

Laravel Chunking - You Might Be Doing This Wrong - Problem and Solution:

Laravel Tip - Properly Get Data Between Two Dates

Get Data From Multiple Databases In One Project | Laravel Tip

#laravel #php #laraveltip #laratips
Рекомендации по теме
Комментарии
Автор

Glad they finally added native support for this!
Now we just need the encrypted cast to gracefully handle plaintext column values when unencrypted records already exist

sleeplessdev
Автор

so just one time to be able changing key right? next time it can't be ?

BrangSeng-zn
Автор

so now you can have two keys, if the new one can't be verified, Laravel will use the old one, amarite?

ricko
Автор

What about the leaked data according to the previous key?
Can we protect it too, or the new key will be bounded to the new data only?

ShadiMuhammad
Автор

Sir please my laravel project have an error please will you help me?

geetarani