From bd1f9422b5702b24fa04257e8caaff188305ea90 Mon Sep 17 00:00:00 2001 From: Florent Gluck <florent.gluck@hesge.ch> Date: Wed, 10 Jul 2024 18:55:17 +0200 Subject: [PATCH] Minor renaming. Fixed access bug in VMSpiceCredsAny --- src/server/router/router.go | 2 +- src/server/router/routerVMs.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/server/router/router.go b/src/server/router/router.go index fc66077..35fce78 100644 --- a/src/server/router/router.go +++ b/src/server/router/router.go @@ -92,7 +92,7 @@ func (router *Router)Start(port int) { vmsGroup.PUT("/:id/start", router.vms.StartVM) vmsGroup.PUT("/:id/startwithcreds", router.vms.StartVMWithCreds) vmsGroup.POST("/:id/spicecreds", router.vms.VMSpiceCreds) - vmsGroup.POST("/spicecreds", router.vms.AnyVMSpiceCreds) + vmsGroup.POST("/spicecreds", router.vms.VMSpiceCredsAny) vmsGroup.PUT("/:id/stop", router.vms.KillVM) vmsGroup.PUT("/:id/shutdown", router.vms.ShutdownVM) vmsGroup.PUT("/:id/reboot", router.vms.RebootVM) diff --git a/src/server/router/routerVMs.go b/src/server/router/routerVMs.go index 29fbd14..64148fc 100644 --- a/src/server/router/routerVMs.go +++ b/src/server/router/routerVMs.go @@ -205,14 +205,14 @@ func (r *RouterVMs)VMSpiceCreds(c echo.Context) error { // Returns the Spice credentials for the VM matching the specific VM attach password. // Requires the CAP_VM_ATTACH_ANY user capability: // curl --cacert ca.pem -X POST https://localhost:1077/vms/spicecreds -H 'Content-Type: application/json' -d '{"pwd":"46L8drgZ5Dx"}' -H "Authorization: Bearer <AccessToken>" -func (r *RouterVMs)AnyVMSpiceCreds(c echo.Context) error { +func (r *RouterVMs)VMSpiceCredsAny(c echo.Context) error { // Retrieves logged user from context. user, err := getLoggedUser(r.users, c) if err != nil { return echo.NewHTTPError(http.StatusUnauthorized, err.Error()) } - if user.HasCapability(caps.CAP_VM_ATTACH_ANY) { + if !user.HasCapability(caps.CAP_VM_ATTACH_ANY) { return echo.NewHTTPError(http.StatusUnauthorized, errors.New("Access denied")) } -- GitLab