|
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 66-69
sub new {
Link Here
|
| 66 |
); |
68 |
); |
| 67 |
} |
69 |
} |
| 68 |
|
70 |
|
|
|
71 |
=head3 qr_dataurl |
| 72 |
|
| 73 |
=cut |
| 74 |
|
| 75 |
sub qr_dataurl { |
| 76 |
my ( $self ) = @_; |
| 77 |
|
| 78 |
my $otpauth = $self->qr_code( undef, undef, undef, 1); |
| 79 |
# no need to pass secret, key and issuer again |
| 80 |
my $qrcode = Imager::QRCode->new({ |
| 81 |
size => 8, # 200 x 200 |
| 82 |
margin => 2, |
| 83 |
version => 1, |
| 84 |
level => 'M', |
| 85 |
casesensitive => 1, |
| 86 |
lightcolor => Imager::Color->new(255, 255, 255), |
| 87 |
darkcolor => Imager::Color->new(0, 0, 0), |
| 88 |
}); |
| 89 |
my $img = $qrcode->plot( $otpauth ); |
| 90 |
my $data; |
| 91 |
$img->write( data => \$data, type => 'png' ); |
| 92 |
return "data:image/png;base64,". encode_base64( $data, q{} ); # does not contain newlines |
| 93 |
} |
| 94 |
|
| 69 |
1; |
95 |
1; |