diff --git a/README.md b/README.md index c6de301..503c1cc 100644 --- a/README.md +++ b/README.md @@ -153,6 +153,8 @@ services: # Google OAuth configuration (optional) - GOOGLE_CLIENT_ID=your_google_client_id - GOOGLE_CLIENT_SECRET=your_google_client_secret + # Two-Factor Authentication configuration + - TOTP_ENCRYPTION_KEY=your_32_byte_secure_encryption_key # Email configuration - EMAIL_ENABLED=true - EMAIL_HOST=smtp.example.com @@ -225,6 +227,9 @@ EMAIL_ENABLE_TLS=true EMAIL_REQUIRE_AUTH=true EMAIL_USERNAME=smtp_username EMAIL_PASSWORD=smtp_password + +# Two-Factor Authentication configuration +TOTP_ENCRYPTION_KEY=your_32_byte_encryption_key_here ``` ### Configuration Options @@ -249,6 +254,14 @@ EMAIL_PASSWORD=smtp_password - `EMAIL_ENABLE_TLS`: Set to `true` to use TLS for secure email transmission - `EMAIL_REQUIRE_AUTH`: Set to `true` to require authentication for SMTP connections, or `false` for servers that don't need authentication +- Two-Factor Authentication (2FA) configuration: + - `TOTP_ENCRYPTION_KEY`: Secret key used to encrypt/decrypt TOTP secrets (for 2FA) + - Should be exactly 32 bytes (characters) for optimal security + - If not set, a default development key will be used (not secure for production) + - If shorter than 32 bytes, it will be automatically padded (less secure) + - If longer than 32 bytes, it will be truncated to 32 bytes + - Example: `TOTP_ENCRYPTION_KEY=abcdefghijklmnopqrstuvwxyz123456` + ### Logging Configuration GoMFT provides configurable logging with rotation support through the following environment variables: @@ -370,6 +383,13 @@ The following fields have been added to the `users` table: - Enter the 6-digit code from your authenticator app - Alternatively, use a backup code if you can't access your authenticator +#### Security Considerations +- The TOTP secrets are encrypted using AES-256-GCM +- You must set the `TOTP_ENCRYPTION_KEY` environment variable in production +- This key should be 32 bytes (characters) long and kept confidential +- Changing this key after users have set up 2FA will invalidate their existing 2FA configurations +- For high-security deployments, store this key in a secure vault and inject it at runtime + ### Transfer Configuration Options 1. **Source/Destination Types**: diff --git a/components/profile.templ b/components/profile.templ index 700fa79..eca0c2b 100644 --- a/components/profile.templ +++ b/components/profile.templ @@ -153,27 +153,39 @@ templ Profile(ctx context.Context, user db.User) {
These codes can be used to login if you lose access to your authenticator app
+These codes are your backup method to access your account.
+You don't have any backup codes. Generate new ones for account recovery.
+ +Enter one of your backup codes
+
+ Lost your device?
+
+ You can use one of your backup codes instead of the 6-digit code.
+