|
Lines 17-22
package Koha::Auth::TwoFactorAuth;
Link Here
|
| 17 |
|
17 |
|
| 18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
| 19 |
use Auth::GoogleAuth; |
19 |
use Auth::GoogleAuth; |
|
|
20 |
use Imager::QRCode; |
| 21 |
use MIME::Base64 qw( encode_base64 ); |
| 20 |
|
22 |
|
| 21 |
use base qw( Auth::GoogleAuth ); |
23 |
use base qw( Auth::GoogleAuth ); |
| 22 |
|
24 |
|
|
Lines 68-71
sub new {
Link Here
|
| 68 |
); |
70 |
); |
| 69 |
} |
71 |
} |
| 70 |
|
72 |
|
|
|
73 |
=head3 qr_dataurl |
| 74 |
|
| 75 |
=cut |
| 76 |
|
| 77 |
sub qr_dataurl { |
| 78 |
my ( $self ) = @_; |
| 79 |
|
| 80 |
my $otpauth = $self->qr_code( $self->secret32, $self->key_id, $self->issuer, 1); |
| 81 |
my $qrcode = Imager::QRCode->new({ |
| 82 |
size => 8, # 200 x 200 |
| 83 |
margin => 2, |
| 84 |
version => 1, |
| 85 |
level => 'M', |
| 86 |
casesensitive => 1, |
| 87 |
lightcolor => Imager::Color->new(255, 255, 255), |
| 88 |
darkcolor => Imager::Color->new(0, 0, 0), |
| 89 |
}); |
| 90 |
my $img = $qrcode->plot( $otpauth ); |
| 91 |
my $data; |
| 92 |
$img->write( data => \$data, type => 'png' ); |
| 93 |
return "data:image/png;base64,". encode_base64( $data ); |
| 94 |
} |
| 95 |
|
| 71 |
1; |
96 |
1; |