andreasnij / lockout-authentication
该软件包已被废弃且不再维护。未建议替代软件包。
带锁定功能的简单认证器。
2.0
2022-01-18 23:09 UTC
Requires
- php: >=7.4
Requires (Dev)
- phpstan/phpstan: ^1.3
- phpunit/phpunit: ^9.5
- squizlabs/php_codesniffer: ^3.6
This package is auto-updated.
Last update: 2024-03-29 11:50:26 UTC
README
这个简单的PHP认证器使用内置的PHP密码哈希和验证函数来验证实现提供的接口的用户对象。它具有锁定机制,在用户多次登录失败后,禁止用户登录几分钟,使暴力攻击变得不那么有效。
安装
将包添加到您的composer.json
文件中作为需求
$ composer require andreasnij/lockout-authenticator
使用方法
use LockoutAuthentication\Authenticator; $authenticator = new Authenticator(); if ($authenticator->authenticate($user, $_POST['password'])) { // Place code to login user here echo 'You are now logged in!'; } elseif ($authenticator->isLoginBlocked()) { echo 'Your account has temporarily been locked due to multiple ' . 'failed login attempts. Try again later.'; } else { echo 'The username or password is incorrect!'; } // Place code to save the $user object to persistent storage here
需求
- 锁定认证器需要PHP 7.4或更高版本。
作者
Andreas Nilsson http://github.com/andreasnij
许可证
锁定认证器遵循MIT许可证 - 有关详细信息,请参阅LICENSE文件。