Search by

illuma-law / laravel-vault-cipher

miguelenes

Tenant-aware streaming encryption for Laravel.

Package info

github.com/eloquage/laravel-vault-cipher

pkg:composer/illuma-law/laravel-vault-cipher

Statistics

Installs: 64

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 2

v0.1.5 2026-10-23 14:03 UTC

This package is auto-updated.

Last update: 2026-10-23 14:04:18 UTC


README

Laravel Vault Cipher tenant encryption banner

Encrypt strings and files with tenant-specific keys in Laravel applications. You provide the key storage and lookup implementation; the package supplies the encryption manager, streaming file support, and Eloquent casts.

Tests Latest Version License

Requires PHP 8.3+ and Laravel 11, 12, or 13.

Install

composer require illuma-law/laravel-vault-cipher
php artisan vendor:publish --tag=vault-cipher-config

Configure a key provider

Implement TenantKeyProvider to look up each tenant's key from your secure key store. This example assumes the key is encrypted in a Tenant model using Laravel's application key; use a dedicated KMS or vault when appropriate.

namespace App\Security;

use App\Models\Tenant;
use IllumaLaw\VaultCipher\Contracts\TenantKeyProvider;

final class DatabaseTenantKeyProvider implements TenantKeyProvider
{
    public function getKey(int|string $tenantId): string
    {
        $encryptedKey = Tenant::query()->findOrFail($tenantId)->encrypted_data_key;

        return decrypt($encryptedKey);
    }
}

Set the provider class in config/vault-cipher.php:

'key_provider' => App\Security\DatabaseTenantKeyProvider::class,

Generate compatible keys with VaultKeyGenerator::generate() and store them securely for their tenant.

Encrypt strings and files

use IllumaLaw\VaultCipher\Facades\TenantEncryptionManager;

$encrypted = TenantEncryptionManager::encryptString($tenantId, 'private text');
$plainText = TenantEncryptionManager::decryptString($tenantId, $encrypted);

TenantEncryptionManager::store($tenantId, 'contracts/agreement.pdf', $contents);
$contents = TenantEncryptionManager::get($tenantId, 'contracts/agreement.pdf');

File operations use the configured filesystem disk by default. You can pass a disk explicitly or use usingDecryptedTempPath() to process a temporary plaintext file that is cleaned up after the callback.

For Eloquent attributes, use TenantEncrypted or TenantEncryptedArray and implement TenantCipherable to provide the model's tenant ID.

Test

composer test
composer analyse
vendor/bin/pint --test

MIT licensed. See LICENSE.