jandreasn / 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: 2023-03-02 21:44:00 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
要求
- Lockout Authenticator需要PHP 7.4或更高版本。
作者
Andreas Nilsson http://github.com/andreasnij
许可
Lockout Authenticator遵循MIT许可证 - 详细内容请参阅LICENSE文件。