ikechukwukalu/requirepin
Composer 安装命令:
composer require ikechukwukalu/requirepin
包简介
A laravel package for pin confirmation and validation before processing requests to a specified route
README 文档
README
RequirePin is a Laravel package that provides middleware to enforce PIN confirmation and validation before processing requests to specified routes, adding an extra layer of security to your application.
Table of Contents
- Requirements
- Installation
- Configuration
- Usage
- Customization
- Reserved Keys for Payload
- To Display Return Payload Within Blade
- Security Considerations
- Contributing
- License
Requirements
- PHP 7.3 or higher
- Laravel 8 or higher
Installation
To install the package, run the following command:
composer require ikechukwukalu/requirepin
After installation, publish the migration files:
php artisan vendor:publish --tag=rp-migrations
Then, run the migrations:
php artisan migrate
Configure your .env file to use Redis for queue management:
REDIS_CLIENT=predis QUEUE_CONNECTION=redis
Finally, start the queue worker:
php artisan queue:work
Configuration
RequirePin uses Redis to manage PIN confirmation queues efficiently. Ensure that your Redis server is properly configured and running.
Usage
Applying Middleware
To enforce PIN confirmation on specific routes, apply the require.pin middleware to those routes or route groups. For example:
Route::middleware(['require.pin'])->group(function () { // Protected routes });
Routes
The package provides the following routes:
API Routes:
POST api/change/pin: Endpoint to change the user's PIN.POST api/pin/required/{uuid}: Endpoint to confirm the PIN for a specific request.
Web Routes:
POST change/pin: Endpoint to change the user's PIN.POST pin/required/{uuid}: Endpoint to confirm the PIN for a specific request.GET change/pin: Page to display the form for changing the PIN.GET pin/required/{uuid?}: Page to display the form for PIN confirmation.
Note: To receive JSON responses, add the 'Accept: application/json' header to your requests.
Reserved Keys for Payload
The following keys are reserved for use within the payload:
uuid- Unique identifier for the PIN request.pin- The PIN value submitted by the user.expires- Expiration time for the PIN request.signature- Timestamp indicating when the PIN was verified.return_payloadpin_validation
Ensure these keys are not overridden when handling the payload.
To Display Return Payload Within Blade
To display the returned payload values within a Blade template, use:
@if (session('return_payload')) @php [$status, $status_code, $data] = json_decode(session('return_payload'), true); @endphp <div class="alert alert-{!! $status === 'fail' ? 'danger' : 'success' !!} m-5 text-center"> {!! $data['message'] !!} </div> @endif
You can customize this based on your application's needs.
Security Considerations
- PIN Policies: Ensure that your application enforces strong PIN policies, such as minimum length and complexity requirements.
- Rate Limiting: Implement rate limiting on PIN confirmation endpoints to prevent brute-force attacks.
- Secure Storage: Store PINs securely using appropriate hashing algorithms.
Contributing
Contributions are welcome! Please read the contribution guidelines before submitting a pull request.
License
This package is open-sourced software licensed under the MIT license.
ikechukwukalu/requirepin 适用场景与选型建议
ikechukwukalu/requirepin 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 11.37k 次下载、GitHub Stars 达 247, 最近一次更新时间为 2023 年 03 月 02 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 ikechukwukalu/requirepin 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ikechukwukalu/requirepin 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 11.37k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 247
- 点击次数: 7
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-03-02