[Bug 44006] New: Allow staff to enrol in two-factor authentication using email instead of an authenticator app
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44006 Bug ID: 44006 Summary: Allow staff to enrol in two-factor authentication using email instead of an authenticator app Initiative type: --- Sponsorship --- status: Product: Koha Version: Main Hardware: All OS: All Status: NEW Severity: normal Priority: P5 - low Component: Authentication Assignee: koha-bugs@lists.koha-community.org Reporter: martin.renvoize@openfifth.co.uk QA Contact: martin.renvoize@openfifth.co.uk CC: dpavlin@rot13.org Target Milestone: --- Currently the only way to enrol in 2FA is to scan a QR code with an authenticator app. The email fallback (Bug 44005) only helps users who already enrolled with an app. Proposed: offer "Email" as an enrolment choice on the 2FA page (members/two_factor_auth.pl). This reuses the existing TOTP machinery with no schema change: - registration generates a secret as it does now, but the QR code and key are never shown (the pending secret is kept server side in the session) - a code derived from that secret is emailed to the user's notice email address - the user enters the code; on success the secret is stored, auth_method is set to two-factor and the 2FA_ENABLE notice is queued - at login, the existing "Send the code by email" link delivers the code Email enrolment is offered only when TwoFactorAuthenticationEmailFallback is enabled and the patron has a notice email address, since these users can only log in via the fallback. The preference text should warn that turning it off will lock out users who enrolled by email (misc/admin/reset_2fa.pl is the recovery path). Test plan: 1. Enable TwoFactorAuthentication and TwoFactorAuthenticationEmailFallback. 2. As a staff user with an email address, open the 2FA page and choose Email. 3. Confirm no QR code is shown, and a code arrives by email. 4. Enter the code: 2FA is enabled and the 2FA_ENABLE notice is queued. 5. Log out and in: at the second step use "Send the code by email" and log in with the code. 6. Disable the fallback preference: the Email choice is no longer offered. 7. A user without an email address is not offered the Email choice. -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44006 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Depends on| |44005 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44005 [Bug 44005] Add a system preference to enable or disable the email fallback for two-factor authentication -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44006 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |44007 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44007 [Bug 44007] Limit attempts and resends on the two-factor authentication second step -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44006 --- Comment #1 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 210565 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=210565&action=edit Bug 44006: Allow staff to enrol in two-factor authentication using email Until now the only way to enrol in 2FA was to scan a QR code with an authenticator app. This adds an "Use email instead of an app" option to the enrolment screen, both on the patron 2FA page and on the forced setup screen shown at login when 2FA is enforced. No schema change: this reuses the existing TOTP machinery. - POST /api/v1/auth/two-factor/registration/email generates a secret, keeps it server side in the session (it is never sent to the browser) and emails a code derived from it to the patron. - POST /api/v1/auth/two-factor/registration/email/verification checks the code, then stores the secret, enables 2FA and queues the 2FA_ENABLE notice, as the app flow does. - At login the existing "Send the code by email" link delivers the code. The option is only offered when TwoFactorAuthenticationEmailFallback is enabled and the patron has a notice email address. Users enrolled by email can only log in via that fallback, so the preference description now warns that turning it off locks them out until 2FA is reset. To test: 1. Apply the patch, restart_all, and apply the Bug 44005 patch first. 2. Set TwoFactorAuthentication to Enable and TwoFactorAuthenticationEmailFallback to Allow. 3. As a staff user with an email address, go to the 2FA page, click Enable two-factor authentication, then "Use email instead of an app". 4. Confirm the QR code and key are hidden and a code is emailed. 5. Enter the code: 2FA is enabled and the 2FA_ENABLE notice is queued. 6. Log out and in: use "Send the code by email" and log in with it. 7. Set TwoFactorAuthenticationEmailFallback to Don't allow: the email option is no longer offered, and the endpoints return 403. 8. A staff user without an email address is not offered the option. 9. Set TwoFactorAuthentication to Enforce and log in as a user without 2FA: the setup screen offers the same email option. 10. prove t/db_dependent/api/v1/two_factor_auth.t Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44006 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff Assignee|koha-bugs@lists.koha-commun |martin.renvoize@openfifth.c |ity.org |o.uk -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44006 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44006 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #210565|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44006 --- Comment #2 from David Nind <david@davidnind.com> --- Created attachment 210807 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=210807&action=edit Bug 44006: Allow staff to enrol in two-factor authentication using email Until now the only way to enrol in 2FA was to scan a QR code with an authenticator app. This adds an "Use email instead of an app" option to the enrolment screen, both on the patron 2FA page and on the forced setup screen shown at login when 2FA is enforced. No schema change: this reuses the existing TOTP machinery. - POST /api/v1/auth/two-factor/registration/email generates a secret, keeps it server side in the session (it is never sent to the browser) and emails a code derived from it to the patron. - POST /api/v1/auth/two-factor/registration/email/verification checks the code, then stores the secret, enables 2FA and queues the 2FA_ENABLE notice, as the app flow does. - At login the existing "Send the code by email" link delivers the code. The option is only offered when TwoFactorAuthenticationEmailFallback is enabled and the patron has a notice email address. Users enrolled by email can only log in via that fallback, so the preference description now warns that turning it off locks them out until 2FA is reset. To test: 1. Apply the patch, restart_all, and apply the Bug 44005 patch first. 2. Set TwoFactorAuthentication to Enable and TwoFactorAuthenticationEmailFallback to Allow. 3. As a staff user with an email address, go to the 2FA page, click Enable two-factor authentication, then "Use email instead of an app". 4. Confirm the QR code and key are hidden and a code is emailed. 5. Enter the code: 2FA is enabled and the 2FA_ENABLE notice is queued. 6. Log out and in: use "Send the code by email" and log in with it. 7. Set TwoFactorAuthenticationEmailFallback to Don't allow: the email option is no longer offered, and the endpoints return 403. 8. A staff user without an email address is not offered the option. 9. Set TwoFactorAuthentication to Enforce and log in as a user without 2FA: the setup screen offers the same email option. 10. prove t/db_dependent/api/v1/two_factor_auth.t Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: David Nind <david@davidnind.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44006 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- QA Contact|martin.renvoize@openfifth.c |dcook@prosentient.com.au |o.uk | -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org