View | Details | Raw Unified | Return to bug 29873
Collapse All | Expand All

(-)a/Koha/Auth/TwoFactorAuth.pm (+25 lines)
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;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/two_factor_auth.tt (-1 / +1 lines)
Lines 55-61 Link Here
55
                            <ol>
55
                            <ol>
56
                                <li>
56
                                <li>
57
                                    <label for="qr_code">QR code: </label>
57
                                    <label for="qr_code">QR code: </label>
58
                                    <img id="qr_code" src="[% qr_code_url | url %]" />
58
                                    <img id="qr_code" src="[% qr_dataurl | url %]" />
59
                                </li>
59
                                </li>
60
                                <li>
60
                                <li>
61
                                    <label for="pin_code">Pin code: </label>
61
                                    <label for="pin_code">Pin code: </label>
(-)a/members/two_factor_auth.pl (-4 / +1 lines)
Lines 79-92 if ( $op eq 'enable-2FA' ) { Link Here
79
        { patron => $logged_in_user, secret => $secret } );
79
        { patron => $logged_in_user, secret => $secret } );
80
80
81
    my $secret32 = $auth->generate_secret32;
81
    my $secret32 = $auth->generate_secret32;
82
    my $qr_code_url =
83
      $auth->qr_code( $secret32, $auth->key_id, $auth->issuer, );
84
82
85
    $template->param(
83
    $template->param(
86
        issuer      => $auth->issuer,
84
        issuer      => $auth->issuer,
87
        key_id      => $auth->key_id,
85
        key_id      => $auth->key_id,
88
        secret32    => $secret32,
86
        secret32    => $secret32,
89
        qr_code_url => $qr_code_url,
87
        qr_dataurl  => $auth->qr_dataurl,
90
    );
88
    );
91
    $auth->clear;
89
    $auth->clear;
92
    $op = 'register';
90
    $op = 'register';
93
- 

Return to bug 29873