定制 asmari/laravel-secure-docs 二次开发

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

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

asmari/laravel-secure-docs

Composer 安装命令:

composer require asmari/laravel-secure-docs

包简介

A Laravel package to securely encrypt and store ID documents (KTP, SIM, etc).

README 文档

README

Laravel Secure Docs is a robust package for securely encrypting and storing sensitive user documents (ID Cards, Passports, Contracts) in Laravel applications.

It uses AES-256-CBC encryption to ensure that files are encrypted before they touch the disk. Even if your storage volume is compromised, the files remain unreadable without your application's APP_KEY.

Features

  • Zero-Knowledge Storage: Files are stored as encrypted blobs (.dat).
  • Filename Hashing: Original filenames are hidden; storage paths are randomized.
  • On-the-Fly Decryption: Files are decrypted in memory only when requested.
  • Polymorphic: Attach secure documents to any model (User, Employee, Company, etc.).
  • Laravel 10, 11, & 12 Ready.

Requirements

  • PHP ^8.1
  • Laravel ^10.0, ^11.0, or ^12.0

Installation

Run:

composer require asmari/laravel-secure-docs:dev-main

Setup

  1. Run Migrations Publish the package migration to create the secure_documents table:
php artisan migrate
  1. Add the Trait Add the HasSecureDocs trait to any model that needs to upload documents (e.g., User, Employee).
namespace App\Models;

use Illuminate\Foundation\Auth\User as Authenticatable;
use Asmari\SecureDocs\Traits\HasSecureDocs; // <--- Import

class User extends Authenticatable
{
    use HasSecureDocs; // <--- Enable

    // ...
}

Usage

  1. Encrypting & Uploading In your Controller, use the uploadSecureDoc method. This handles encryption, hashing, and database linking automatically.
public function store(Request $request)
{
    $request->validate([
        'id_card' => 'required|file|mimes:jpg,png,pdf|max:2048'
    ]);

    // Automatically encrypts, hashes, and saves metadata
    $user = auth()->user();
    $user->uploadSecureDoc($request->file('id_card'));

    return back()->with('success', 'Document encrypted successfully!');
}
  1. Decrypting & Viewing To view a file, use the model to fetch the metadata and stream the decrypted content.

Controller Example:

use Asmari\SecureDocs\Models\SecureDocument;

public function show($id)
{
    $doc = SecureDocument::findOrFail($id);

    // Authorization: Ensure user owns this file (or use a Policy)
    if ($doc->model_id !== auth()->id()) {
        abort(403);
    }

    // 'decrypted_content' is a helper attribute that decrypts on the fly
    return response($doc->decrypted_content)
        ->header('Content-Type', $doc->mime_type)
        ->header('Content-Disposition', 'inline; filename="' . $doc->original_name . '"');
}

Blade View Example:

<a href="{{ route('docs.show', $doc->id) }}" target="_blank">
    View Encrypted File
</a>

⚠️ Critical Security Notice

This package relies on your Laravel application's APP_KEY (found in .env).

  1. Do NOT lose your APP_KEY. If you change or lose this key, all encrypted files will become permanently unreadable (garbage data).

  2. Backup your APP_KEY securely.

  3. Ensure your storage/app/private_docs folder is not symlinked to public/. It must remain private.

asmari/laravel-secure-docs 适用场景与选型建议

asmari/laravel-secure-docs 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 13 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 12 月 14 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-12-14