定制 minvws/laravel-crypto 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

minvws/laravel-crypto

Composer 安装命令:

composer require minvws/laravel-crypto

包简介

Laravel provider for crypto functionality

README 文档

README

To learn more about the crypto used in the projects, please take a look at our crypto doc.

Requirements

  • PHP >= 8.0
  • Laravel >= 8.0

Installation

  1. Install the package via composer:
composer require minvws/laravel-crypto
  1. If you are running Laravel 5.5 or higher (the package will be auto-discovered), skip this step. Find the providers array key in config/app.php and register the Laravel Crypto Service Provider:
'providers' => [
    ...
    MinVWS\Laravel\Providers\CryptoServiceProvider::class,
];

Usage

This section describes the usage of the different crypto functionalities

CMS Crypto

CMS crypto allows you to easily encrypt (and possibly decrypt) data.

Usage:

class UserController {
    
    protected CmsCryptoInterface $service;
    
    function index()
    {
        $cipherText = $this->service->encrypt('plaintext');
        return new JsonResponse(['data' => $cipherText]);        
    }
}

Sealbox Crypto

class UserController {
    
    protected SealboxCryptoInterface $service;
    
    function index()
    {
        $cipherText = $this->service->encrypt('plaintext');
        return new JsonResponse(['data' => $cipherText]);        
    }
}

Signatures

class UserController {
    
    protected SignatureCryptoInterface $service;
    
    function index()
    {
        $sig = $this->service->sign('foobar', false);
        return new JsonResponse(['signature' => $sig]);        
    }
}

Laravel HTTP Middleware

Step 1: Add to app/Http/Kernel.php:

/*/ Package Middleware /*/
    ...
    'cms_sign' => \MinVWS\Crypto\Laravel\Http\Middleware\CmsSignature::class,

Step 2: Add your middleware to your routes:

Route::middleware('cms_sign')->post(
    '/my/route',
    [RouteController::class, 'index']
);

Environment vars

# OpenSSL CMS encryption
CMS_ENCRYPTION_CERT_PATHS        A comma separated list of x509 certificate paths that are used for encrypting data 
CMS_DECRYPTION_CERT_PATH         A certificate file path that is used for decrypting data (optional)  
CMS_DECRYPTION_CERT_KEY_PATH     The key file for the cert that is used for decrypting data (optional)  

# LibSodium sealbox
CMS_SEAL_PRIVKEY            Our own private X25519 key
CMS_SEAL_RECIPIENT_PUBKEY   Public X25519 key of the recipient

# OpenSSL CMS signing
CMS_SIGN_X509_CERT          The certificate file to sign the data
CMS_SIGN_X509_KEY           The key file to sign the data
CMS_SIGN_X509_PASS          Optional passphrase for the key file
CMS_SIGN_X509_CHAIN         Optional chain of certificates to be added to the signed data

Running tests

Tests are run based on your PHP version. On PHP7, openssl functionality that is not available, will not be tested.

Running tests when you don't have PHP8 (but have docker):

You can still test PHP8 functionality when running PHP7 by using the PHP8 docker image:

docker run -ti -w /app -v $PWD:/app php:8-cli php /app/vendor/bin/phpunit

Using code coverage on PHP8:

docker run -ti -w /app -v $PWD:/app php:8-cli phpdbg -qrr /app/vendor/bin/phpunit --coverage-html=./html

minvws/laravel-crypto 适用场景与选型建议

minvws/laravel-crypto 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.19k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2022 年 01 月 03 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 minvws/laravel-crypto 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 3
  • Watchers: 13
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: EUPL-1.2
  • 更新时间: 2022-01-03