nojimage/cakephp-login-attempts

CakePHP 登录尝试插件

安装次数: 12,809

依赖项: 0

建议者: 0

安全性: 0

星标: 6

关注者: 2

分支: 2

开放问题: 0

类型:cakephp-plugin

v3.0.2 2024-03-01 14:44 UTC

This package is auto-updated.

Last update: 2024-08-31 00:29:35 UTC


README

Software License Build Status Codecov Latest Stable Version

需求

安装

您可以使用 composer 将此插件安装到您的 CakePHP 应用程序中。

安装 composer 包的推荐方法是

composer require nojimage/cakephp-login-attempts"^3.0

加载插件

通过在项目的 src/Application.php 文件中添加以下语句来加载插件:

$this->addPlugin('LoginAttempts');

创建表

运行迁移命令

bin/cake migrations migrate -p LoginAttempts

用法

使用 LoginAttempts.Form 验证器代替 Form

如果使用认证插件

        $service->loadAuthenticator('LoginAttempts.Form', [
            'fields' => ['username' => 'email'],
            'attemptLimit' => 5,
            'attemptDuration' => '+5 minutes',
        ]);

LoginAttempts.Form 选项

attemptLimit

如果用户的登录失败次数在 attemptDuration 期间超过 attemptLimit,则不允许用户登录。

默认: 5

attemptDuration

如果用户的登录失败次数在 attemptDuration 期间超过 attemptLimit,则不允许用户登录。

默认: +5 minutes'

attemptAction

为该键存储尝试次数。当有多个登录表单且需要分别设置限制时使用。

默认: 'login'

attemptsStorageModel

用于记录失败登录和检查失败登录数量的模型。

默认: 'LoginAttempts.Attempts'