A TOTP (Time-Based One-Time Password) Two-Factor Authentication Module for codeigniter4/shield
Project should have a stability level of dev
composer config minimum-stability dev
composer config prefer-stable true
composer require grimpirate/halberd:dev-develop
The TOTP authenticator class must be added to the Config/Auth file
...
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,
];
...
A spark command is provided to finalize installation. It will use codeigniter4/settings to set up the configuration for: Auth.views, Auth.actions, TOTP.issuer and TOTP.stylesheet
php spark halberd:ini
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.
The QR Code will not be visible without creating a stylesheet and applying some basic styles, for instance
svg
{
width: 100%;
height: 240px;
fill-rule: evenodd;
}