feat: TOTP 2FA + diverse Verbesserungen

2FA (TOTP):
- backend/api/auth.go: zweistufiger Login-Flow mit Pending-Token (5min),
  Endpunkte /2fa/validate, /2fa/setup, /2fa/confirm, /2fa/disable
- backend/db/users.go: GetUserByID, SetTOTPSecret, EnableTOTP, DisableTOTP
- backend/db/postgres.go: Migration totp_secret + totp_enabled Spalten
- backend/models/user.go: TOTPEnabled/TOTPSecret Felder, neue Request-Typen
- backend/main.go: neue Routen registriert (/2fa/validate ohne Auth, rest geschuetzt)
- backend/go.mod+sum: github.com/pquerna/otp hinzugefuegt
- frontend/src/pages/Login.jsx: zweistufiger Login (Passwort -> TOTP)
- frontend/src/pages/SettingsPage.jsx: TwoFactorSection mit Setup/Deaktivieren
- frontend/src/stores/auth.js: validateTOTP Action
- frontend/src/api/client.js: setupTOTP, confirmTOTP, disableTOTP, validateTOTP

Weitere Aenderungen (unstaged -> jetzt committed):
- frontend/src/components/ScriptModal.jsx: neu
- frontend/src/components/AgentPanel.jsx: Erweiterungen
- frontend/src/components/ProxmoxPanel.jsx: Erweiterungen
- agent-linux/ws/handler.go: Erweiterungen
- backend/api/scheduler.go + tasks.go: Erweiterungen
- backend/db/tasks.go + models/task.go: Erweiterungen
This commit is contained in:
cynfo3000
2026-03-08 19:17:43 +01:00
parent c76868e806
commit 10684dfc0a
19 changed files with 926 additions and 98 deletions
+2
View File
@@ -21,6 +21,8 @@ type Task struct {
HealthCheck bool `json:"health_check"`
HealthCheckTimeout int `json:"health_check_timeout"`
SecurityOnly bool `json:"security_only,omitempty"`
Script string `json:"script,omitempty"`
ScriptTimeout int `json:"script_timeout,omitempty"`
WebhookURL string `json:"webhook_url,omitempty"`
WebhookSent bool `json:"webhook_sent"`
WebhookResponse string `json:"webhook_response,omitempty"`
+26 -3
View File
@@ -8,6 +8,8 @@ type User struct {
PasswordHash string `json:"-"`
DisplayName string `json:"display_name"`
Role string `json:"role"`
TOTPEnabled bool `json:"totp_enabled"`
TOTPSecret string `json:"-"`
CreatedAt time.Time `json:"created_at"`
LastLogin *time.Time `json:"last_login,omitempty"`
}
@@ -18,7 +20,28 @@ type LoginRequest struct {
}
type LoginResponse struct {
Token string `json:"token"`
ExpiresAt string `json:"expires_at"`
User User `json:"user"`
Token string `json:"token,omitempty"`
ExpiresAt string `json:"expires_at,omitempty"`
User *User `json:"user,omitempty"`
TOTPRequired bool `json:"totp_required,omitempty"`
TOTPToken string `json:"totp_token,omitempty"`
}
type TOTPValidateRequest struct {
TOTPToken string `json:"totp_token"`
Code string `json:"code"`
}
type TOTPSetupResponse struct {
Secret string `json:"secret"`
URI string `json:"uri"`
}
type TOTPConfirmRequest struct {
Code string `json:"code"`
}
type TOTPDisableRequest struct {
Password string `json:"password"`
Code string `json:"code"`
}