salines/cakephp-verification
Composer 安装命令:
composer require salines/cakephp-verification
包简介
Verification and step-up authentication for CakePHP 5: email verification links, Email OTP, SMS OTP, and TOTP.
README 文档
README
A CakePHP 5.x plugin for step-up verification and MFA: email verification links, Email OTP, SMS OTP, and TOTP (authenticator apps).
Features
emailVerify— email verification linkemailOtp— email one-time codesmsOtp— SMS one-time codetotp— TOTP / authenticator apps (RFC 6238, no external library needed for code generation)- Pluggable SMS transports (dummy driver included)
- Optional at-rest encryption of the TOTP secret (Sodium or AES-256-GCM)
- Rate-limiting, lockout, and resend cooldown for OTP codes
VerificationComponenthandles all controller logic (auto-start, verify, mark verified, redirect)- Works with integer and UUID user primary keys
Requirements
- PHP 8.2+
- CakePHP 5.3+
- cakephp/authentication ^4.0
- bacon/bacon-qr-code (optional, for SVG QR rendering in TOTP enrollment)
How It Works
The plugin adds two verification gates to your application:
1. Setup flow — runs once, immediately after registration. The user must
complete every step listed in requiredSetupSteps before they can access the
app. Steps are executed in order:
emailVerify— user receives a confirmation link; clicks it to confirm their address. Until confirmed, all other steps are blocked.- OTP enrollment — if
emailOtp,smsOtp, ortotpare listed, the user enrolls in the chosen method (enters a code, scans a QR, etc.).
If more than one OTP driver is listed in
requiredSetupStepsthe user is first directed to a choose-verification screen where they pick which method they want to use. See docs/verification_flow.md.
2. Login flow — runs on every subsequent login, after the user authenticates with their password. The plugin checks which OTP method the user enrolled in and redirects them to enter a code before they reach the app.
The plugin relies on the CakePHP Authentication identity object to identify the
current user. It does not manage its own session. Persistent verification
results (email_verified_at, totp_secret, verification_preferences, …)
are written to your users table. OTP codes and rate-limiting state are stored
temporarily in the CakePHP Cache (auto-deleted after use or expiry).
Installation
composer require salines/cakephp-verification bin/cake plugin load Verification bin/cake verification:install
Add the required columns to your users table (see migration example in the full guide),
then implement the UsersController actions.
See docs/installation.md for the full installation guide.
Configuration
Open config/verification.php and set the steps your app needs:
'Verification' => [ 'enabled' => true, // Available steps: 'emailVerify', 'emailOtp', 'smsOtp', 'totp' // emailVerify always runs first (blocks other steps until confirmed). // If more than one OTP step is listed, the user is asked to choose one. 'requiredSetupSteps' => ['emailVerify', 'emailOtp'], 'routing' => [ 'nextRoute' => ['plugin' => false, 'controller' => 'Users', 'action' => 'verify'], 'pendingRoute' => ['plugin' => false, 'controller' => 'Users', 'action' => 'pending'], 'enrollRoute' => ['plugin' => false, 'controller' => 'Users', 'action' => 'enroll'], 'enrollPhoneRoute' => ['plugin' => false, 'controller' => 'Users', 'action' => 'enrollPhone'], 'chooseVerificationRoute' => ['plugin' => false, 'controller' => 'Users', 'action' => 'chooseVerification'], 'onVerifiedRoute' => ['plugin' => false, 'controller' => 'Users', 'action' => 'index'], ], 'storage' => [ 'maxAttempts' => 5, 'lockoutSeconds' => 900, 'resendCooldown' => 60, ], ],
See docs/configuration.md for the full configuration reference.
Setup
Component
Load VerificationComponent alongside Authentication in AppController:
// src/Controller/AppController.php public function initialize(): void { parent::initialize(); $this->loadComponent('Flash'); $this->loadComponent('Authentication.Authentication'); $this->loadComponent('CakeVerification.Verification'); }
See docs/verification_component.md for the full component API.
Helper
VerificationHelper is auto-loaded by the plugin. It provides qrCode() for
TOTP enrollment views and lastSmsCode() for debug-mode SMS inspection.
See docs/verification_helper.md for details.
Available Steps
| Key | Type | Description |
|---|---|---|
emailVerify |
Setup only | Send link by email; user clicks to confirm |
emailOtp |
Setup/Login | Send numeric code by email |
smsOtp |
Setup/Login | Send numeric code by SMS |
totp |
Setup/Login | TOTP code from authenticator app (RFC 6238) |
Documentation
Full documentation index: docs/index.md. Start with installation, then the configuration reference and environment variables.
License
MIT License. See LICENSE for details.
salines/cakephp-verification 适用场景与选型建议
salines/cakephp-verification 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 25 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 02 月 22 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「Authentication」 「plugin」 「email」 「sms」 「cakephp」 「otp」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 salines/cakephp-verification 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 salines/cakephp-verification 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 salines/cakephp-verification 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
CakePHP 4.x AdminLTE Theme.
Automatically logs-in users if they are already authenticated by a remote source. (e.g. environment variable REMOTE_USER)
GraphQL authentication for your headless Craft CMS applications.
Laravel middleware to restrict a site or specific routes using HTTP basic authentication
Email Toolkit Plugin for CakePHP
Extensible library for building notifications and sending them via different delivery channels.
统计信息
- 总下载量: 25
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 34
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-02-22