cynfo3000 10684dfc0a 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
2026-03-08 19:17:43 +01:00

48 lines
1.2 KiB
Go

package models
import "time"
type User struct {
ID int `json:"id"`
Username string `json:"username"`
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"`
}
type LoginRequest struct {
Username string `json:"username"`
Password string `json:"password"`
}
type LoginResponse struct {
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"`
}