Bug 30843: Add mfa_range configuration option for TOTP
authorDavid Cook <dcook@prosentient.com.au>
Wed, 6 Sep 2023 05:12:50 +0000 (05:12 +0000)
committerMatt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
Tue, 17 Oct 2023 16:56:21 +0000 (16:56 +0000)
commitdaf3b688fd39a77e42229c2cf4e26ec8f36cfc0d
tree4fb47a9804021b2fef5cb41bf783129630575c58
parent5169ed8e8f5ec2cdacc23fde04beddac53975015
Bug 30843: Add mfa_range configuration option for TOTP

This change adds a mfa_range configuration option for TOTP
to koha-conf.xml, and overrides the "verify" method from
Auth::GoogleAuth in order to provide a new default for "range"

Test plan:
0. Apply the patch
1. koha-plack --restart kohadev
2. Go to
http://localhost:8081/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=TwoFactorAuthentication
3. Change the syspref to "Enable"
4. Go to
http://localhost:8081/cgi-bin/koha/members/moremember.pl?borrowernumber=51
5. Click "More" and "Manage two-factor authentication"
6. Register using an app
7. In an Incognito window, go to
http://localhost:8081/cgi-bin/koha/mainpage.pl
8. Sign in with the "koha" user
9. Note down a code from your Authenticator app
10. Wait until after 60 seconds and try it
11. Note it says "Invalid two-factor code"
12. Try a new code from the app
13. Note that it works

14. Add <mfa_range>10</mfa_range> to /etc/koha/sites/kohadev/koha-conf.xml
15. Clear memcached and koha-plack --restart kohadev
16. Sign in with the "koha" user
17. Note down a code from your Authenticator app
18. Wait 4 minutes and then try it
19. Note that it works

20. Disable your two-factor authentication and click to re-enable it
21. Use a code older than 60 seconds when registering for the two
factor authentication
22. Note that the code works

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit 6a0955946e06354ecd05f714057a878794314155)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
(cherry picked from commit 5cef65a87f516ba3e04137f2f114a6a191d0f034)
Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
C4/Auth.pm
Koha/Auth/TwoFactorAuth.pm
Koha/REST/V1/TwoFactorAuth.pm
debian/templates/koha-conf-site.xml.in
etc/koha-conf.xml