2017 © Pedro Peláez
 

symfony-bundle doctrine-encryption-bundle

Doctrine encryption bundle for Symfony to aid with GDPR and general field encryption

image

brandoriented/doctrine-encryption-bundle

Doctrine encryption bundle for Symfony to aid with GDPR and general field encryption

  • Wednesday, May 23, 2018
  • by BrandOriented
  • Repository
  • 0 Watchers
  • 0 Stars
  • 5 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Doctrine Encryption Bundle

With GDPR becoming business critical here's a bundle that handles the data encryption layer., (*1)

Installation

composer require brandoriented/doctrine-encryption-bundle dev-master, (*2)

   app/AppKernel.php


    public function registerBundles()
    {
        $bundles = [
            ...
            new BrandOriented\Encryption\DoctrineEncryptionBundle(),
            ...
        ];
    }

Configuration

Basic, (*3)

Basic configuration will take advantage of the encryption library provided, (*4)

doctrine_encryption:
  key: 'an encryption key'
  iv: 'an encryption iv'
  suffix: 'an encryption suffix'

Full, (*5)

doctrine_encryption:
  key: 'an encryption key'
  iv: 'an encryption iv'
  suffix: 'an encryption suffix'
  method: 'AES-256-CBC' // This is the default setting
  class: 'Full\Namespace\To\Your\Encryptor' // If not supplied will use the default

Usage

Using the encryption service in controller

use BrandOriented\Encryption\Bridge\Bridge;

$this->get(Bridge::class)->encrypt($string)
$this->get(Bridge::class)->decrypt($string);

Entity Annotation

    use BrandOriented\Encryption\Annotation\Encrypted;

    class User {
       /**
       * @Encrypted()
       */
       private $firstname;

    }

The above will auto encrypt on prePersist and preUpdate, (*6)

Twig

{{ user.firstname | decrypt }}

Design decision

You'll notice there is no postLoad event to convert back to decrypted. Experience with doctrine is that as the entity is changed it adds it to the queue to be flushed. Say if you have an account with 1000 users each user would be decrypted meaning re saved., (*7)

How to add a custom Encryptor

Create a class that extends BrandOriented\Encryption\Encryptor\EncryptorInterface. Then register as mentioned in the above config., (*8)

Tests

Yes there a loads of lovely unit tests :), (*9)

Roadmap

  • [ ] Form inputs
  • [ ] Command line util
  • [ ] Travis integration

The Versions

23/05 2018

dev-master

9999999-dev https://github.com/BrandOriented/doctrine-encryption-bundle

Doctrine encryption bundle for Symfony to aid with GDPR and general field encryption

  Sources   Download

MIT

The Requires

 

by Matthew Thomas

orm bundle doctrine symfony encryption gdpr

23/05 2018

1.1.1

1.1.1.0 https://github.com/BrandOriented/doctrine-encryption-bundle

Doctrine encryption bundle for Symfony to aid with GDPR and general field encryption

  Sources   Download

MIT

The Requires

 

by Matthew Thomas

orm bundle doctrine symfony encryption gdpr