brainlet-ali/laravel-locksmith
Composer 安装命令:
composer require brainlet-ali/laravel-locksmith
包简介
Secrets rotation orchestration for Laravel with zero-downtime grace periods.
README 文档
README
Secrets rotation orchestration for Laravel.
Manage the complete lifecycle of credential rotation: generate, validate, swap, and cleanup - with zero downtime.
Why Locksmith?
- Zero-downtime rotation - Grace periods let both old and new keys work during transition
- Self-cleaning - Old keys automatically deleted from providers after grace period
- Rotation lifecycle - Generate → Validate → Swap → Cleanup, all orchestrated
- Notifications - Get alerted on rotation success/failure via Mail or Slack
- Audit logging - Track every rotation with correlation IDs
- Open source - MIT licensed, forever free
Installation
composer require brainlet-ali/laravel-locksmith php artisan locksmith:install
Two Ways to Rotate
| Method | For | How |
|---|---|---|
| Recipes | Services with key-generation APIs | Locksmith creates new keys via API |
| Key Pools | Services without APIs | You pre-add keys, Locksmith rotates through them |
Quick Start
Recipe-based (AWS IAM):
php artisan locksmith:init aws.credentials # Stores username + first key
php artisan locksmith:rotate aws.credentials --recipe=aws
Output:
Discarding previous key for [aws.credentials]...
Rotating secret [aws.credentials]...
Secret [aws.credentials] rotated successfully.
Key Pool (services without APIs):
php artisan locksmith:pool api.secret --add # Add pre-generated keys php artisan locksmith:pool api.secret --rotate # Rotate to next key
Read secrets:
$secret = Locksmith::get('api.secret');
Commands
locksmith:install # Interactive setup locksmith:init # Initialize credentials locksmith:rotate # Rotate with recipe locksmith:rollback # Rollback to previous locksmith:status # View secrets status locksmith:clear-expired # Clear expired grace periods locksmith:prune-logs # Remove old rotation logs locksmith:pool # Manage key pools locksmith:pool-rotate # Rotate all configured pools
Self-Cleaning Rotation
Locksmith automatically manages key lifecycle:
┌─────────────────────────────────────────────────────────────────┐
│ ROTATE │
│ ├── Discard previous_value immediately (if exists) │
│ ├── Generate new key via recipe │
│ ├── Validate new key works │
│ ├── Store: value=new, previous_value=old │
│ └── Schedule cleanup job (runs after grace period) │
│ │
│ GRACE PERIOD (60 min default) │
│ ├── Both old and new keys work │
│ └── Applications gradually switch to new key │
│ │
│ AFTER GRACE PERIOD (automatic) │
│ ├── Job runs: deletes old key from provider (AWS, etc.) │
│ └── Clears previous_value from database │
│ │
│ ROTATE AGAIN (on-demand) │
│ ├── Discards current previous_value BEFORE generating new │
│ └── Prevents hitting provider key limits (AWS = 2 keys max) │
└─────────────────────────────────────────────────────────────────┘
Built-in Recipe
| Recipe | What it does |
|---|---|
AwsRecipe |
Rotates IAM access keys with self-managed credentials |
Self-managed AWS credentials:
- Username, Access Key ID, and Secret stored encrypted in Locksmith
- No
.envvariables needed for AWS - User rotates their own keys (IAM permissions on self)
- Old keys auto-deleted from AWS after grace period
Features
- AES-256 encryption at rest
- Dual-key grace periods (zero downtime)
- Self-cleaning rotation with scheduled jobs
- On-demand discard for immediate rotation
- Scheduled rotation via Laravel scheduler
- Mail & Slack notifications
- Audit logging with correlation IDs
- Caching layer (reduces DB calls)
Requirements
- PHP 8.1+
- Laravel 9.x, 10.x, or 11.x
Documentation
Full docs: docs/DOCUMENTATION.md
License
MIT
brainlet-ali/laravel-locksmith 适用场景与选型建议
brainlet-ali/laravel-locksmith 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3 次下载、GitHub Stars 达 8, 最近一次更新时间为 2025 年 12 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「security」 「encryption」 「laravel」 「credentials」 「secrets」 「rotation」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 brainlet-ali/laravel-locksmith 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 brainlet-ali/laravel-locksmith 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 brainlet-ali/laravel-locksmith 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A simple PHP class to encrypt a string and decrypt an encrypted string
A package for automatically encrypting and decrypting Eloquent attributes in Laravel 5.5+, based on configuration settings.
Provide a way to secure accesses to all routes of an symfony application.
Encryption with AES-256 and HMAC-SHA256
Allows installation of Laravel where the PHP Mcrypt extension is not available. Provides encryption using OpenSSL, or by disabling encryption entierly.
High-level cryptographic primitives and security utilities for Maatify systems including password hashing, reversible encryption, HKDF key derivation, and key rotation.
统计信息
- 总下载量: 3
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 8
- 点击次数: 33
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-12-07