Koha::Auth::TwoFactorAuth- Koha class deal with Two factor authentication
use Koha::Auth::TwoFactorAuth;
my $secret = Koha::AuthUtils::generate_salt( 'weak', 16 ); my $auth = Koha::Auth::TwoFactorAuth->new({ patron => $patron, secret => $secret }); my $image_src = $auth->qr_code; my $ok = $auth->verify( $pin_code, 1 );
It's based on Auth::GoogleAuth
$obj = Koha::Auth::TwoFactorAuth->new({ patron => $p, secret => $s }); Patron is mandatory. Secret is optional, defaults to patron's secret. Passing secret32 overrules secret! Secret32 should be base32.
my $image_src = $auth->qr_code; Replacement for (unsafer) Auth::GoogleAuth::qr_code. Returns the data URL to fill the src attribute of the image tag on the registration form.
my $verified = $auth->verify($otp_token); Replacement for Auth::GoogleAuth::verify. This uses a system wide default for range.