grimpirate/halberd

CodeIgniter4 Google 两步验证模块 for Shield

dev-develop 2024-09-18 16:58 UTC

This package is auto-updated.

Last update: 2024-09-18 16:58:46 UTC


README

codeigniter4/shield 提供的 TOTP(基于时间的单次密码)两步验证模块

安装

项目应具有 dev 稳定性级别

composer config minimum-stability dev
composer config prefer-stable true
composer require grimpirate/halberd:dev-develop

配置

必须将 TOTP 验证器类添加到 Config/Auth 文件中

...

class Auth extends BaseConfig
{

  ...

  public array $authenticators = [
    'tokens'  => AccessTokens::class,
    'session' => Session::class,
    'hmac'    => HmacSha256::class,
    // 'jwt'     => JWT::class,
    'totp'    => \GrimPirate\Halberd\Authentication\Authenticators\TOTP::class,
  ];

  ...

提供了一个 spark 命令以完成安装。它将使用 codeigniter4/settings 来设置以下配置:Auth.views, Auth.actions, TOTP.issuer 和 TOTP.stylesheet

php spark halberd:ini

依赖 pragmarx/google2fa 要求您的服务器时间准确同步(通过 NTP 或其他方式)。CodeIgniter 的 appTimezone 不会影响 OTP 生成。

如果没有创建样式表并应用一些基本样式,例如,二维码将不可见。

svg
{
  width: 100%;
  height: 240px;
  fill-rule: evenodd;
}