Skip to content

2.2.0

Compare
Choose a tag to compare
@tonysm tonysm released this 16 Mar 19:12
· 34 commits to main since this release
15a0e37

What's Changed

  • Allow configuring the encryption handlers by @tonysm in #52

Full Changelog: 2.1.0...2.2.0


Upgrade Guide

It's now recommended that you add a RichTextLaravel::encryptAsString() to your AppServiceProvider::boot method. If you have existing data stored encrypted, you'll have to migrate them manually (see instructions below). This is an opt-in feature, but it's highly recommended to store encrypted rich text attributes as string (the default way will serialize the value before encrypting, which is not needed).

In the next major version, we'll switch to encrypt as string by default.

Migrating Existing Encrypted Data

If you only have encrypted rich text attributes in your application, you may create a new migration and loop through the stored data, encrypting and decrypting it:

DB::table('rich_texts')->whereNotNull('body')->eachById(function ($richText) {
  DB::table('rich_texts')
    ->where('id', $richText->id)
    ->update([
      'body' => Crypt::encryptString(Crypt::decrypt($richText->body)),
    ]);
});

Make sure you add the RichTextLaravel::encryptAsString() to your AppServiceProvider::boot method.

If you have a mix of encrypted and plain text rich text attributes, you will have to check if the $richText->field and $richText->record_type fields match the entities and attribute that are using encryption:

DB::table('rich_texts')
  ->whereNotNull('body')
  ->where('field', 'content')
  ->where('record_type', (new Post())->getMorphClass())
  ->eachById(function ($richText) {
    DB::table('rich_texts')
      ->where('id', $richText->id)
      ->update([
        'body' => Crypt::encryptString(Crypt::decrypt($richText->body)),
      ]);
  });