fix: SSHAuthenticator vide après installation + logs debug
Bug principal : l'SSHAuthenticator est créé au démarrage avec host="" (DB vide avant installation). Après configure, il gardait host vide. Le login lisait maintenant le ssh_host depuis la DB à chaque requête. Logs ajoutés : - ssh_auth.go : dial SSH, succès, échec avec détail d'erreur - auth.go : host SSH utilisé, résultat auth à chaque login - updates.go : credentials SSH, démarrage/fin de job - terminal.go : ouverture/échec session SSH Frontend : - auth.store.ts : gère les réponses non-JSON sur erreur HTTP Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
15965082ce
commit
07af66ad81
5 changed files with 46 additions and 7 deletions
|
|
@ -6,6 +6,7 @@ package auth
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net"
|
||||
"strings"
|
||||
"time"
|
||||
|
|
@ -45,8 +46,10 @@ func (a *SSHAuthenticator) Authenticate(username, password string) (*UserInfo, e
|
|||
}
|
||||
|
||||
// Tentative de connexion SSH
|
||||
log.Printf("[ssh_auth] Dial %s@%s...", username, a.host)
|
||||
client, err := ssh.Dial("tcp", a.host, config)
|
||||
if err != nil {
|
||||
log.Printf("[ssh_auth] Échec dial %s@%s : %v", username, a.host, err)
|
||||
// Distinguer les erreurs d'authentification des erreurs réseau
|
||||
if strings.Contains(err.Error(), "unable to authenticate") ||
|
||||
strings.Contains(err.Error(), "ssh: handshake failed") ||
|
||||
|
|
@ -56,13 +59,15 @@ func (a *SSHAuthenticator) Authenticate(username, password string) (*UserInfo, e
|
|||
return nil, fmt.Errorf("connexion SSH impossible : %w", err)
|
||||
}
|
||||
defer client.Close()
|
||||
log.Printf("[ssh_auth] Connexion établie — %s@%s", username, a.host)
|
||||
|
||||
// Vérifier l'appartenance aux groupes sudo/wheel via la commande `id`
|
||||
isAdmin, err := checkSudoGroup(client)
|
||||
if err != nil {
|
||||
// En cas d'erreur de vérification des groupes, l'utilisateur est authentifié mais pas admin
|
||||
log.Printf("[ssh_auth] Avertissement vérification sudo — user=%s : %v", username, err)
|
||||
isAdmin = false
|
||||
}
|
||||
log.Printf("[ssh_auth] Authentifié — user=%s admin=%v", username, isAdmin)
|
||||
|
||||
return &UserInfo{
|
||||
Username: username,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue