From 35303d97f2f92b8ee321fd30c073c5b94f5acfd8 Mon Sep 17 00:00:00 2001 From: wanyaoqi Date: Sat, 8 Oct 2022 14:03:13 +0800 Subject: [PATCH] fix(host-image): cancel auth host-image http requests --- pkg/hostimage/host_image_service.go | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/pkg/hostimage/host_image_service.go b/pkg/hostimage/host_image_service.go index ebb8c5f6e7..17c21ddd49 100644 --- a/pkg/hostimage/host_image_service.go +++ b/pkg/hostimage/host_image_service.go @@ -35,7 +35,6 @@ import ( "yunion.io/x/onecloud/pkg/cloudcommon/consts" common_options "yunion.io/x/onecloud/pkg/cloudcommon/options" "yunion.io/x/onecloud/pkg/httperrors" - "yunion.io/x/onecloud/pkg/mcclient/auth" "yunion.io/x/onecloud/pkg/util/seclib2" ) @@ -79,15 +78,15 @@ func StartService() { } func initHandlers(app *appsrv.Application, prefix string) { - app.AddHandler("GET", fmt.Sprintf("%s/disks/", prefix), auth.Authenticate(getImage)). + app.AddHandler("GET", fmt.Sprintf("%s/disks/", prefix), getImage). SetProcessNoTimeout().SetWorkerManager(streamingWorkerMan) - app.AddHandler("GET", fmt.Sprintf("%s/snapshots//", prefix), auth.Authenticate(getImage)). + app.AddHandler("GET", fmt.Sprintf("%s/snapshots//", prefix), getImage). SetProcessNoTimeout().SetWorkerManager(streamingWorkerMan) - app.AddHandler("HEAD", fmt.Sprintf("%s/disks/", prefix), auth.Authenticate(getImageMeta)) - app.AddHandler("HEAD", fmt.Sprintf("%s/snapshots//", prefix), auth.Authenticate(getImageMeta)) - app.AddHandler("POST", fmt.Sprintf("%s/disks/", prefix), auth.Authenticate(closeImage)) - app.AddHandler("POST", fmt.Sprintf("%s/snapshots//", prefix), auth.Authenticate(closeImage)) + app.AddHandler("HEAD", fmt.Sprintf("%s/disks/", prefix), getImageMeta) + app.AddHandler("HEAD", fmt.Sprintf("%s/snapshots//", prefix), getImageMeta) + app.AddHandler("POST", fmt.Sprintf("%s/disks/", prefix), closeImage) + app.AddHandler("POST", fmt.Sprintf("%s/snapshots//", prefix), closeImage) } func getDiskPath(diskId string) string { @@ -112,11 +111,6 @@ func getSnapshotPath(diskId, snapshotId string) string { } func inputCheck(ctx context.Context) (string, error) { - var userCred = auth.FetchUserCredential(ctx, nil) - if !userCred.HasSystemAdminPrivilege() { - return "", httperrors.NewForbiddenError("System admin only") - } - var params = appctx.AppContextParams(ctx) var sid = params[""] var imagePath string