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 GD::Barcode; |
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_code |
72 |
|
73 |
my $image_src = $auth->qr_code; |
74 |
|
75 |
Replacement for (unsafer) Auth::GoogleAuth::qr_code. |
76 |
Returns the data URL to fill the src attribute of the |
77 |
image tag on the registration form. |
78 |
|
79 |
=cut |
80 |
|
81 |
sub qr_code { |
82 |
my ( $self ) = @_; |
83 |
|
84 |
my $otpauth = $self->SUPER::qr_code( undef, undef, undef, 1); |
85 |
# no need to pass secret, key and issuer again |
86 |
my $qrcode = GD::Barcode->new( 'QRcode', $otpauth, { Ecc => 'M', Version => 8, ModuleSize => 4 } ); |
87 |
my $data = $qrcode->plot->png; |
88 |
return "data:image/png;base64,". encode_base64( $data, q{} ); # does not contain newlines |
89 |
} |
90 |
|
69 |
1; |
91 |
1; |