jandreasn/lockout-authentication

此包已被废弃且不再维护。作者建议使用andreasnij/lockout-authentication包。

带有锁定功能的简单认证器。

2.0 2022-01-18 23:09 UTC

This package is auto-updated.

Last update: 2023-03-02 21:44:00 UTC


README

Latest Stable Version

这个简单的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文件。