fix issue with proxmox session binding

This commit is contained in:
2026-03-27 23:02:36 +00:00
parent f17ae26506
commit a1a18af016
3 changed files with 14 additions and 3 deletions

View File

@@ -29,11 +29,17 @@ func NewClientFromCredentials(config common.PVEConfig, username common.Username,
client := proxmox.NewClient(config.URL,
proxmox.WithHTTPClient(&HTTPClient),
proxmox.WithCredentials(&proxmox.Credentials{Username: username.ToString(), Password: password}),
proxmox.WithCredentials(&proxmox.Credentials{Username: username.UserID, Realm: username.Realm, Password: password}),
)
// todo this should return an error code if the binding failed (ie fetch version to check if the auth was actually ok)
// check that the user is authenticated because proxmox.NewClient does not return an error
// version route is accessible to any authenticated user
_, err := client.Version(context.Background())
if err != nil { // could not get version so therefore the user is not authenticated
return nil, http.StatusUnauthorized, err
}
// todo this should return an error code if the binding failed (ie fetch version to check if the auth was actually ok)
return &ProxmoxClient{config: &config, client: client}, http.StatusOK, nil
}