项目作者: bcrowe

项目描述 :
:lock_with_ink_pen: CakePHP 4 plugin that provides application-level database encryption.
高级语言: PHP
项目地址: git://github.com/bcrowe/cakephp-encrypted-type.git
创建时间: 2017-09-08T16:25:02Z
项目社区:https://github.com/bcrowe/cakephp-encrypted-type

开源协议:MIT License

下载


CakePHP Encrypted Type

Latest Version on Packagist
Software License
Build Status
Coverage Status
Quality Score
Total Downloads

This plugin provides a CakePHP 4 encrypted database type for application-level
encryption. Before using this plugin you may want to weigh your options
between full-disk, database-level, and application-level encryption.
This plugin was born out of Amazon Aurora not supporting encryption with cross
region replication before March 28, 2017.

Install

Via Composer

  1. $ composer require bcrowe/cakephp-encrypted-type

Load the plugin in your application’s bootstrap.php file, then define the type
mapping:

  1. Plugin::load('BryanCrowe/EncryptedType');
  2. Type::map('encrypted', 'BryanCrowe\EncryptedType\Database\Type\EncryptedType');

Make sure to have a Encryption.key config value in your config/app.php file:

  1. [
  2. 'Encryption' => [
  3. 'key' => env('ENCRYPTION_KEY', 'defaultencryptionkeygoesrighthereyaythisisfun'),
  4. ],
  5. ]

Usage

Note: This database type expects columns to be nullable in the case of an
omitted column or whenever explicitly setting a null value for a column.

Use BLOB types for columns that are to be encrypted, for example:

  1. CREATE TABLE `users` (
  2. `id` char(36) NOT NULL DEFAULT '',
  3. `first_name` blob,
  4. `last_name` blob,
  5. `email` blob,
  6. `created` datetime DEFAULT NULL,
  7. `modified` datetime DEFAULT NULL,
  8. PRIMARY KEY (`id`)
  9. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;

Map the type
to a column in your Table class:

  1. <?php
  2. namespace App\Model\Table;
  3. use Cake\Database\Schema\TableSchema;
  4. use Cake\ORM\Table;
  5. class UsersTable extends Table
  6. {
  7. protected function _initializeSchema(TableSchema $schema)
  8. {
  9. $schema->columnType('first_name', 'encrypted');
  10. $schema->columnType('last_name', 'encrypted');
  11. $schema->columnType('email', 'encrypted');
  12. return $schema;
  13. }
  14. }

Changelog

Please see CHANGELOG for more information what has changed
recently.

Testing

  1. $ composer test

Contributing

Please see CONTRIBUTING and CONDUCT for
details.

Security

If you discover any security related issues, please email bryan@bryan-crowe.com
instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more
information.