Implement TOTP two-factor authentication (RFC 6238) with Yubikey support#9189
Implement TOTP two-factor authentication (RFC 6238) with Yubikey support#9189
Conversation
Co-authored-by: ehuelsmann <2326559+ehuelsmann@users.noreply.github.com>
Co-authored-by: ehuelsmann <2326559+ehuelsmann@users.noreply.github.com>
Co-authored-by: ehuelsmann <2326559+ehuelsmann@users.noreply.github.com>
- Use cryptographically secure random source (/dev/urandom) for TOTP secret generation - Fix lockout check to properly verify if lockout period has expired - Fix SQL function variable scope issue in user__totp_verify_and_update Co-authored-by: ehuelsmann <2326559+ehuelsmann@users.noreply.github.com>
- Remove insecure fallback random generation; fail securely if /dev/urandom unavailable - Add clarifying comment about credential validation flow in login - Fix SQL lockout status check to verify timestamp is in future - Fix JavaScript header comparison to be case-insensitive - Anchor HTML pattern regex to prevent partial matches Co-authored-by: ehuelsmann <2326559+ehuelsmann@users.noreply.github.com>
- Anchor regex pattern in JavaScript TOTP input validation - Fix Enter key handler to call callback directly - Add periods to documentation list items for consistency Co-authored-by: ehuelsmann <2326559+ehuelsmann@users.noreply.github.com>
|
@copilot thanks! Can you add the option to allow Yubikey TOTP too? |
- Add 'digits' attribute to TOTP module (supports 6 or 8 digits) - Update verify_code to accept configured digit length - Update UI to accept 6-8 digit codes - Update login and user management to try both 6 and 8-digit verification - Update documentation to mention Yubikey compatibility - Add tests for 8-digit code verification Co-authored-by: ehuelsmann <2326559+ehuelsmann@users.noreply.github.com>
Yubikey TOTP support has been added in commit 3a28913. The implementation now accepts both 6-digit (standard) and 8-digit (Yubikey default) codes. Key changes:
Yubikeys and all other RFC 6238 compliant TOTP devices are now fully supported. |
|
@copilot, please move this branch to my repository ( ehuelsmann/LedgerSMB ). |
I don't have the ability to move branches between GitHub repositories as that requires repository administrative permissions. To move this branch to ehuelsmann/LedgerSMB, you'll need to:
The code changes are all committed and ready - they just need to be pushed to the target repository through standard git operations. |
|
Saved on my own repository; closing this branch. |
Adds optional TOTP-based two-factor authentication to complement username/password login. Feature is disabled by default and users opt-in individually. Supports both standard 6-digit codes and 8-digit codes for Yubikey compatibility.
Core Implementation
lib/LedgerSMB/TOTP.pm: RFC 6238 compliant TOTP module/dev/urandomdigitsattribute (default: 6, supports: 8)lib/LedgerSMB/Scripts/login.pm: Authentication flow integrationX-LedgerSMB-TOTP-Required: 1header when code neededDatabase schema (
sql/changes/1.13/add-totp-support.sql):totp_secret,totp_enabled,totp_failures,totp_last_used,totp_locked_untilcolumns onuserstableadmin__totp_enable_user,admin__totp_disable_user,user__totp_verify_and_updateUser Interface
UI/users/totp_setup.html)UI/users/totp_status.html)UI/js-src/lsmb/TOTPLogin.js)Configuration
Security Features
totp_last_usedtimestamp trackingSupported Devices
Dependencies
Auth::GoogleAuth: TOTP implementationConvert::Base32: Secret encodingGD::Barcode::QRcode: QR generationExample Usage
Testing
Unit tests in
t/13.1-totp.tcover secret generation, code verification (both 6 and 8-digit), QR generation, and error handling.Original prompt
This pull request was created from Copilot chat.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.