grimpirate/halberd

CodeIgniter4 Google Two-Factor Authentication Module for Shield

dev-develop 2025-06-06 01:39 UTC

This package is auto-updated.

Last update: 2025-06-06 01:39:17 UTC


README

A TOTP (Time-Based One-Time Password) Two-Factor Authentication Module for codeigniter4/shield

Installation

Project should have a stability level of dev

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

CLI Configuration

php spark halberd:ini

Manual Configuration

  1. Copy the configuration file from vendor/grimpirate/halberd/app/Config/TOTP.php to your project's app/Config/ directory
  2. Copy the stylesheet from vendor/grimpirate/halberd/public/css/totp.css to your project's app/public/css/ directory
  3. The view, register/login actions and the TOTP authenticator class must be added to the app/Config/Auth.php file
...

class Auth extends BaseConfig
{
  ...

  public array $views = [
    'action_totp_2fa'             => '\GrimPirate\Halberd\Views\totp_2fa_show',
    ...
  ];

  ...

  public array $actions = [
    'register' => \GrimPirate\Halberd\Authentication\Actions\TOTPActivator::class,
    'login'    => \GrimPirate\Halberd\Authentication\Actions\TOTPActivator::class,
  ];

  ...

  public array $authenticators = [
    'totp'    => \GrimPirate\Halberd\Authentication\Authenticators\TOTP::class,
    ...
  ];

  ...

Dependencies

The dependency pragmarx/google2fa requires that your server time be accurately synchronized (via NTP or some other means). CodeIgniter's appTimezone will not affect OTP generation.