Bugzilla – Attachment 129402 Details for
Bug 29873
2FA: Generate QR code without exposing secret via HTTP GET
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29873: Create QR code
Bug-29873-Create-QR-code.patch (text/plain), 3.00 KB, created by
Marcel de Rooy
on 2022-01-13 14:41:44 UTC
(
hide
)
Description:
Bug 29873: Create QR code
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2022-01-13 14:41:44 UTC
Size:
3.00 KB
patch
obsolete
>From a24540ede3b6f87892360c8f68f216268fb6f465 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Thu, 13 Jan 2022 14:27:36 +0000 >Subject: [PATCH] Bug 29873: Create QR code >Content-Type: text/plain; charset=utf-8 > >--- > Koha/Auth/TwoFactorAuth.pm | 25 +++++++++++++++++++ > .../en/modules/members/two_factor_auth.tt | 2 +- > members/two_factor_auth.pl | 4 +-- > 3 files changed, 27 insertions(+), 4 deletions(-) > >diff --git a/Koha/Auth/TwoFactorAuth.pm b/Koha/Auth/TwoFactorAuth.pm >index 8932006763..9f6cd99653 100644 >--- a/Koha/Auth/TwoFactorAuth.pm >+++ b/Koha/Auth/TwoFactorAuth.pm >@@ -17,6 +17,8 @@ package Koha::Auth::TwoFactorAuth; > > use Modern::Perl; > use Auth::GoogleAuth; >+use Imager::QRCode; >+use MIME::Base64 qw( encode_base64 ); > > use base qw( Auth::GoogleAuth ); > >@@ -68,4 +70,27 @@ sub new { > ); > } > >+=head3 qr_dataurl >+ >+=cut >+ >+sub qr_dataurl { >+ my ( $self ) = @_; >+ >+ my $otpauth = $self->qr_code( $self->secret32, $self->key_id, $self->issuer, 1); >+ my $qrcode = Imager::QRCode->new({ >+ size => 8, # 200 x 200 >+ margin => 2, >+ version => 1, >+ level => 'M', >+ casesensitive => 1, >+ lightcolor => Imager::Color->new(255, 255, 255), >+ darkcolor => Imager::Color->new(0, 0, 0), >+ }); >+ my $img = $qrcode->plot( $otpauth ); >+ my $data; >+ $img->write( data => \$data, type => 'png' ); >+ return "data:image/png;base64,". encode_base64( $data ); >+} >+ > 1; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/two_factor_auth.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/two_factor_auth.tt >index 0598fe836d..a9a09b41d2 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/two_factor_auth.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/two_factor_auth.tt >@@ -55,7 +55,7 @@ > <ol> > <li> > <label for="qr_code">QR code: </label> >- <img id="qr_code" src="[% qr_code_url | url %]" /> >+ <img id="qr_code" src="[% qr_dataurl | url %]" /> > </li> > <li> > <label for="pin_code">Pin code: </label> >diff --git a/members/two_factor_auth.pl b/members/two_factor_auth.pl >index 2a5a996c56..da81b781ae 100755 >--- a/members/two_factor_auth.pl >+++ b/members/two_factor_auth.pl >@@ -79,14 +79,12 @@ if ( $op eq 'enable-2FA' ) { > { patron => $logged_in_user, secret => $secret } ); > > my $secret32 = $auth->generate_secret32; >- my $qr_code_url = >- $auth->qr_code( $secret32, $auth->key_id, $auth->issuer, ); > > $template->param( > issuer => $auth->issuer, > key_id => $auth->key_id, > secret32 => $secret32, >- qr_code_url => $qr_code_url, >+ qr_dataurl => $auth->qr_dataurl, > ); > $auth->clear; > $op = 'register'; >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 29873
:
129402
|
129576
|
129577
|
129578
|
129579
|
129580
|
129581
|
129605
|
133216
|
133217
|
133558
|
133559
|
133659
|
133660