morebec/orkestra-postgresql-personal-information-store 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

morebec/orkestra-postgresql-personal-information-store

Composer 安装命令:

composer require morebec/orkestra-postgresql-personal-information-store

包简介

PostgreSQL Personal Information Storage for Orkestra

README 文档

README

This component is a PostgreSQL based implementation of the Orkestra Privacy Component's Personal Information Store. It supports encrypting data in the personal store.

It relies on DBAL for communication with PostgreSQL.

Installation

The component can be installed using composer.

composer require morebec/orkestra-orkestra-postgresql-personal-information-store

Usage

Create a new instance of a PostgreSqlPersonalInformationStore.

use Doctrine\DBAL\Configuration;
use Doctrine\DBAL\DriverManager;
use Morebec\Orkestra\PostgreSqlPersonalInformationStore\PostgreSqlPersonalInformationStore;
use Morebec\Orkestra\PostgreSqlPersonalInformationStore\PostgreSqlPersonalInformationStoreConfiguration;

$connection = DriverManager::getConnection([
    'url' => '...'
], new Configuration()); 

$config = new PostgreSqlPersonalInformationStoreConfiguration();
$config->encryptionKey = PostgreSqlPersonalInformationStore::generateEncryptionKey(); // Or random_bytes(SODIUM_CRYPTO_SECRETBOX_KEYBYTES);
$store = new PostgreSqlPersonalInformationStore($connection,$config);

Ensure you save the encryption key securely such as .env variables or a secret manager.

For more information for how to use the Store, see the documentation for the Privacy Component.

Disposable Information

The information stored in the Personal Information Store can have a disposedAt value which indicates if and when the data should be destroyed. This component ships a DisposedPersonalDataRemover service class that inspects the store for expired data and deletes it.

It should be used in a daemon:

use Morebec\Orkestra\PostgreSqlPersonalInformationStore\DisposedPersonalDataRemover;

$remover = new DisposedPersonalDataRemover($store);

while(true) {
    $remover->run();
    sleep(60);
}

Security

Given the goal of this store is to save Personal Data, the PostgreSQL server must be highly secured against attackers. Here are a few ideas to help you get started.

Client Authentication Control

Client Authentication Control allows to specify the way clients of the PostgreSQL server can connect to it, and if they are allowed to. This configuration can be done in the pg_hba.conf:

# TYPE  DATABASE        USER            ADDRESS                 METHOD
host     postgres       all             172.20.0.0/24           ident
host     all            all             0.0.0.0/0               reject

For example, the above config would only allow all clients with IP address 172.20.0.x to connect to the server on the database postgres using the authentication method ident which works by using the client's operating system username. Given this file is read from top to bottom for a match, the last line would reject any other connection attempts.

Server Configuration

Another thing that can be done to enhance the security of the PostgreSQL server is of course to edit its Server configuration. For example:

  • Changing the default port to something else,
  • Changing the list of allowed client addresses (similar to Client Authentication Control).
  • Using SSL

Testing

To run the tests execute the following command:

vendor/bin/phpunit tests/

It is required to have an instance of postgresql running with a password-less role postgres and a database named postgres. To easily get this setup and running a docker-compose configuration file is available at the root of this project.

To run it simply execute the following command:

docker-compose up -d

morebec/orkestra-postgresql-personal-information-store 适用场景与选型建议

morebec/orkestra-postgresql-personal-information-store 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 402 次下载、GitHub Stars 达 1, 最近一次更新时间为 2021 年 04 月 21 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 morebec/orkestra-postgresql-personal-information-store 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2021-04-21