feat(auth): implement TOTP setup and management
Lint / Lint (Node/Svelte) (push) Successful in 24s
Lint / Lint (Go) (push) Successful in 28s
Lint / Lint (Python) (push) Failing after 14s
Tests / Test (Node/Svelte) (push) Successful in 18s
Tests / Test (Go) (push) Successful in 25s
Tests / Test (Python) (push) Successful in 12s

- Added TOTP support for two-factor authentication in the auth module.
- Introduced new types and interfaces for TOTP setup and token actions in the web UI.
- Created backend logic for generating and verifying TOTP secrets and tokens.
- Implemented user management features including role assignments and user CRUD operations.
- Enhanced UI components for managing users and TOTP settings.
- Added styles for optional labels and authentication reset links.
- Implemented reset code generation and validation for admin accounts.
This commit is contained in:
Gabriel20xx committed 2026-08-05 14:57:01 +02:00
1 parent 2f57554154
commit da97fd4fb1
30 files changed
+2145 -27

No files matched your search

+32
View File
@@ -1,7 +1,9 @@
package auth
import (
"strings"
"testing"
"time"
"golang.org/x/crypto/bcrypt"
)
@@ -35,3 +37,33 @@ func TestNewSessionToken(t *testing.T) {
t.Fatalf("HashToken(raw) = %q, want %q", diff, hash)
}
}
func TestResetManagerRoundTrip(t *testing.T) {
manager := NewResetManager()
code, err := manager.Request()
if err != nil {
t.Fatalf("Request() error = %v", err)
}
if len(code) != 8 || strings.ToUpper(code) != code {
t.Fatalf("reset code = %q, want eight uppercase characters", code)
}
if !manager.Confirm(" " + strings.ToLower(code) + " ") {
t.Fatal("Confirm() rejected a valid reset code")
}
if manager.Confirm(code) {
t.Fatal("Confirm() accepted a reset code twice")
}
}
func TestResetManagerExpiresCode(t *testing.T) {
manager := NewResetManager()
if _, err := manager.Request(); err != nil {
t.Fatalf("Request() error = %v", err)
}
manager.mu.Lock()
manager.expiresAt = time.Now().Add(-time.Second)
manager.mu.Unlock()
if manager.Confirm("anything") {
t.Fatal("Confirm() accepted an expired reset code")
}
}