承接 cleverage/encryption-bundle 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

cleverage/encryption-bundle

Composer 安装命令:

composer require cleverage/encryption-bundle

包简介

The EncryptionBundle allows you to store encrypted files and data in Doctrine's entity in a very simple way

README 文档

README

Easy entity and file encryption for Symfony.

We wanted to be able to store encrypted data in our Symfony2 applications and we realized that there were no simple way to do it.

In our solution, a malicious user will have a really hard time to steal data from our server.

  • The data will not be compromised by an SQL Injection or by a remote include attack.
  • If no end users are connected, no one can decrypt the data, not even the root user.
  • Only users from the same organization can share data between each other.

The idea is to store the cipher key inside the database in the user table but encrypted with the user's plaintext password. This way each user from the same organization can share the same cipher key to encrypt and decrypt data but each user can only decrypt it's own encrypted key at login time.

The main weakness of this system is that the cipher key is stored temporarly in PHP's session, however, the only way to overcome this problem would be to use a pretty complex asymmetric encryption system between the client and the server which could only be done properly using a rich client.

Installation

composer require cleverage/encryption-bundle

Usage

use Doctrine\ORM\Mapping as ORM;

class MyEntity {
    
    /**
     * @ORM\Column(type="encrypt_string") 
     */
    private string $myField;
    
    /**
     * @ORM\Column(type="encrypt_text") 
     */
    private string $myFieldText;
}

Helpers

This bundle comes with an EncryptionManager class which can be used in standalone to encrypt and decrypt data and files. There's also a DecryptFileResponse which allows you to directly stream an encrypted file to the client while deciphering it.

Installation

You just require the package sidus/encryption-bundle either directly in your composer.json or by command line :

$ composer require sidus/encryption-bundle ~0.1.0

Update your AppKernel.php

public function registerBundles()
{
    $bundles = array(
        ...
        new Sidus\EncryptionBundle\SidusEncryptionBundle(),
    );

    ...
}

Implements the interfaces

You should implements the UserEncryptionProviderInterface on your user entity and the CryptableInterface on each entity that will contains encrypted data.

Don't forget to update the model, the encryptedCipherKey must be persisted to the database !

Configuration

If you need to share encrypted data between users you need to generate each encrypted cipher key with the same cipher key which can prove to be tricky, especially if users already have accounts and passwords.

If each user encrypts it's own data however, you can just use the automatic encryption key generation in your config.yml:

sidus_encryption:
    encryption_key:
        auto_generate: false
        throw_exceptions: true # Do not throw an exception when an error occurred when decrypting a value

This will tell the system to automatically generate a new encryption key if the user doesn't have any.

In case of password recovery, the user won't be able to retrieve any of the encrypted data because he would be the only one able to decrypt the cipher key.

Disable Encryption

The encryption can be temporary disabled on an encrypted type (in a command for example). This can be achieved using the Sidus\EncryptionBundle\Encryption\Enabler\EncryptionEnablerInterface service:

// ...
$encryptionEnabler->disableEncryption();

// Starting from here, data will not be decrypted
$encryptionManager->decryptString($value); // The value will not be decrypted
$encryptionManager->encryptString($value); // The value will not be encrypted and store as is

$encryptionEnabler->enableEncryption();
// Now the encryption is re-enabled and works normally

Apache License

@todo

Authors

The bundle was originally created by Vincent Chalnot.

cleverage/encryption-bundle 适用场景与选型建议

cleverage/encryption-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 961 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 11 月 18 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「encryption」 「mcrypt」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 cleverage/encryption-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 cleverage/encryption-bundle 我们能提供哪些服务?
定制开发 / 二次开发

基于 cleverage/encryption-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 961
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-11-18