Bug 33904: Fix 2FA registration when library name has non-latin characters
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Tue, 6 Jun 2023 08:42:20 +0000 (10:42 +0200)
committerMatt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
Wed, 12 Jul 2023 08:51:24 +0000 (08:51 +0000)
commit86fb8f10799384d14c5cae9bd12d11d7fe49bfc6
tree73fcabedfbc997968500b7107eb0c75b79c3ca06
parentff2e43f45617079291639f549b98e0ace65fc03d
Bug 33904: Fix 2FA registration when library name has non-latin characters

If the library name contains non-latin characters, the 2FA registration
process will fail with a JS alert coming from a 500 server-side.

The problem is that Auth::GoogleAuth is expecting an already UTF8 encoded string.
We should set the encoding correctly to make Auth::GoogleAuth deal with
the URL escaping internally correctly, then decode on our own (in the
REST API controller)

Test plan:
* Modify your logged in library name and add some non-latin characters
(eg. "my ❤ library")
* Turn on TwoFactorAuthentication
* Go to your account > More > Manage 2FA
* Click the enable button
=> Notice that you see the QR code and that both "issuer" and "key id"
entries display the library name correctly.
* Test the whole 2FA process, confirm that the library name is correctly
displayed on the app you are using.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit deeb5ebdbd59956f5f6cf1bfa989ef41c9af9720)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
(cherry picked from commit 6678645740787c2e57874eabe4363edd98769d6f)
Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
Koha/Auth/TwoFactorAuth.pm
Koha/REST/V1/TwoFactorAuth.pm