From e538cb2a2680480a57b32cadeb5a787f00b9f96f Mon Sep 17 00:00:00 2001 From: Yousong Zhou Date: Thu, 5 Sep 2019 13:49:25 +0000 Subject: [PATCH] =?UTF-8?q?lbagents:=20deploy:=20=E6=A3=80=E6=9F=A5?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E8=B4=A6=E5=8F=B7=E6=9C=89=E6=95=88=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/compute/models/loadbalanceragents_deploy.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pkg/compute/models/loadbalanceragents_deploy.go b/pkg/compute/models/loadbalanceragents_deploy.go index a5438534ba..98bc3de7de 100644 --- a/pkg/compute/models/loadbalanceragents_deploy.go +++ b/pkg/compute/models/loadbalanceragents_deploy.go @@ -265,6 +265,16 @@ func (lbagent *SLoadbalancerAgent) PerformDeploy(ctx context.Context, userCred m return nil, httperrors.NewBadRequestError("empty host %s field", k) } } + { + cli := mcclient.NewClient(options.Options.AuthURL, 10, false, true, "", "") + token, err := cli.Authenticate(host.Vars["user"], host.Vars["pass"], "", host.Vars["proj"], "") + if err != nil { + return nil, httperrors.NewBadRequestError("authenticate error: %v", err) + } + if !token.HasSystemAdminPrivilege() { + return nil, httperrors.NewBadRequestError("user must have system admin privileges") + } + } host.SetVar("region", options.Options.Region) host.SetVar("auth_uri", options.Options.AuthURL) host.SetVar("id", lbagent.Id)