-
Notifications
You must be signed in to change notification settings - Fork 3.5k
feat: Add TOTP Two-Factor Authentication (2FA) Feature #3885
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
- add pquerna/otp package - add TOTP fields to User and Server structs - add TOTP common error - add symmetric (de)encryption and TOTP code validator function
- add TOTP token expiration time default and update the GetTokenExpirationTime function in settings package - update loginResponse struct and loginHandler - add TOTPEnabled field to userInfo struct - add verifyTOTPHandler to verify TOTP codes - add withTOTP middleware - update getUserID and userGetHandler to remove TOTP fields like password - add userEnableTOTPHandler to initiate TOTP setup - add userGetTOTPHandler and userDisableTOTPHandler for management - add userCheckTOTPHandler to check TOTP setup
- add OTP modal component with its css file - add Profile2FA component for 2FA section in settings page - add @scure/base package to encode OTP secrets in Base32, enabling alternative import options for authenticator apps - add new phrases to the en.json localization file
- add OTP APIs - add OTP prompt to Login page - add Profile2FA to Profile page
This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days. |
This is a nice feature, looking forward to its merge. |
When can merge? I'm looking forward to this feature. |
@MACFORNAME this is quite a large feature and this project is currently in maintenance mode. To learn what it means, please check the readme and the linked resources: https://github.com/filebrowser/filebrowser#project-status |
This PR implements Time-Based One-Time Password (TOTP) 2FA for FileBrowser, enhancing user security by requiring a verification code during login for users with 2FA enabled. It addresses multiple community requests for 2FA support.
Closes #286
Closes #1674
Closes #1827
Closes #2504
Closes #3371
Closes #3800
Description
The TOTP 2FA feature allows users to enable 2FA in their profile settings, scan a QR code or enter a Base32-encoded secret in an authenticator app (e.g., Google Authenticator), and verify codes at login. The flow is:
Further comments
2FA could be handled by reverse proxies like oauth2-proxy or authelia, but this feature simplifies setup without requiring nginx/Apache knowledge.
New options
To enable TOTP, you must configure a 32-byte encryption key in your configuration file.
Generate a cryptographically secure 32-byte Base64-encoded key with this command:
The TOTP token expiration (default: 2 minutes) defines the validity window after initial authentication. Configure this via:
totp-token-expiration-time
option in clitotp > token > expiration > time
in config fileNew dependencies
pquerna/otp
on the back-end for TOTP handling@scure/base
on the front-end for base32 encoding of TOTP secretLocalization
Added phrases to
en.json
but not other languages. Seek community help to translate phrases.Improvements
/api/users/{id}/otp/check
to prevent brute-force attacks.Documentation
While reviewing the documentation, I identified areas for improvement. Could you guide me to the documentation source (e.g., wiki repository) so I may submit updates?
🚨 Before submitting your PR, please indicate which issues are either fixed or closed by this PR. See GitHub Help: Closing issues using keywords.