diff --git a/cmd/climc/shell/natgateways.go b/cmd/climc/shell/natgateways.go index fd20a23352..6135be6763 100644 --- a/cmd/climc/shell/natgateways.go +++ b/cmd/climc/shell/natgateways.go @@ -51,13 +51,13 @@ func init() { R(&NatGatewayListEipOptions{}, "natgateway-dnat-resources", "list resources in dnats of natgateway", func(s *mcclient.ClientSession, opts *NatGatewayListEipOptions) error { - ret, err := modules.NatGateways.PerformAction(s, opts.ID, "dnat-resources", nil) - if err != nil { - return err - } - printObject(ret) - return nil - }) + ret, err := modules.NatGateways.PerformAction(s, opts.ID, "dnat-resources", nil) + if err != nil { + return err + } + printObject(ret) + return nil + }) R(&NatGatewayListEipOptions{}, "natgateway-snat-resources", "list resources in snats of natgateway", func(s *mcclient.ClientSession, opts *NatGatewayListEipOptions) error { diff --git a/pkg/apigateway/handler/auth.go b/pkg/apigateway/handler/auth.go index 2f692ef9ba..3e3f3e392e 100644 --- a/pkg/apigateway/handler/auth.go +++ b/pkg/apigateway/handler/auth.go @@ -72,6 +72,7 @@ func (h *AuthHandlers) AddMethods() { NewHP(h.validatePasscode, "passcode"), NewHP(h.resetTotpRecoveryQuestions, "recovery"), NewHP(h.postLoginHandler, "login"), + NewHP(h.postLogoutHandler, "logout"), ) // auth middleware handler @@ -80,7 +81,6 @@ func (h *AuthHandlers) AddMethods() { NewHP(h.getPermissionDetails, "permissions"), NewHP(h.getAdminResources, "admin_resources"), NewHP(h.getResources, "scoped_resources"), - NewHP(h.postLogoutHandler, "logout"), ) h.AddByMethod(POST, FetchAuthToken, NewHP(h.resetUserPassword, "password"), diff --git a/pkg/compute/tasks/natdentry_delete_task.go b/pkg/compute/tasks/natdentry_delete_task.go index 2410eb2f3b..47c417dd21 100644 --- a/pkg/compute/tasks/natdentry_delete_task.go +++ b/pkg/compute/tasks/natdentry_delete_task.go @@ -21,10 +21,10 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" - "yunion.io/x/onecloud/pkg/cloudprovider" api "yunion.io/x/onecloud/pkg/apis/compute" "yunion.io/x/onecloud/pkg/cloudcommon/db" "yunion.io/x/onecloud/pkg/cloudcommon/db/taskman" + "yunion.io/x/onecloud/pkg/cloudprovider" "yunion.io/x/onecloud/pkg/compute/models" "yunion.io/x/onecloud/pkg/util/logclient" ) diff --git a/pkg/compute/tasks/natsentry_delete_task.go b/pkg/compute/tasks/natsentry_delete_task.go index 31ea208c36..65fbcf768b 100644 --- a/pkg/compute/tasks/natsentry_delete_task.go +++ b/pkg/compute/tasks/natsentry_delete_task.go @@ -21,10 +21,10 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" - "yunion.io/x/onecloud/pkg/cloudprovider" api "yunion.io/x/onecloud/pkg/apis/compute" "yunion.io/x/onecloud/pkg/cloudcommon/db" "yunion.io/x/onecloud/pkg/cloudcommon/db/taskman" + "yunion.io/x/onecloud/pkg/cloudprovider" "yunion.io/x/onecloud/pkg/compute/models" "yunion.io/x/onecloud/pkg/util/logclient" ) diff --git a/pkg/keystone/driver/cas/test/casfe.go b/pkg/keystone/driver/cas/test/casfe.go deleted file mode 100644 index 49f4bee1c3..0000000000 --- a/pkg/keystone/driver/cas/test/casfe.go +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright 2019 Yunion -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package main - -import ( - "context" - "fmt" - "net/http" - "os" - - "yunion.io/x/jsonutils" - - "yunion.io/x/onecloud/pkg/appsrv" - "yunion.io/x/onecloud/pkg/httperrors" - "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/httputils" - "yunion.io/x/onecloud/pkg/util/netutils2" -) - -var ( - authUrl = "" // http://10.168.222.252:35357/v3 - casServer = "" // https://cas.example.org/cas - serviceUrl = "" // https://app.example.com -) - -func defaultPage(ctx context.Context, w http.ResponseWriter, r *http.Request) { - query, err := jsonutils.ParseQueryString(r.URL.RawQuery) - if err != nil { - httperrors.BadRequestError(w, "parse query fail %s", err) - return - } - if query.Contains("ticket") { - ticket, _ := query.GetString("ticket") - service := r.URL.Path - referer := r.Header.Get("Referer") - cliIp := netutils2.GetHttpRequestIp(r) - - cli := mcclient.NewClient(authUrl, 120, true, true, "", "") - token, err := cli.AuthenticateCAS(ticket, "", "", "", cliIp) - if err != nil { - httperrors.InvalidCredentialError(w, "cas auth error %s", err) - return - } - appsrv.SendHTML(w, fmt.Sprintf("

Welcome

[%s]

[%s]

[%s]

[%s]

", ticket, service, referer, token.GetUserName())) - return - } else { - httperrors.HTTPError(w, fmt.Sprintf("%s/login?service=%s", casServer, serviceUrl), 302, "Redirect", httputils.Error{}) - return - } -} - -func main() { - if len(os.Args) <= 6 { - fmt.Printf("usage: %s \n", os.Args[0]) - os.Exit(-1) - return - } - - authUrl = os.Args[1] - casServer = os.Args[2] - serviceUrl = os.Args[3] - certFile := os.Args[4] // "/etc/yunion/certs/nginx-full.crt" - keyFile := os.Args[5] // "/etc/yunion/certs/nginx.key" - port := os.Args[6] // 18443 - - app := appsrv.NewApplication("casfe", 1, false) - app.AddHandler("GET", "/", defaultPage) - app.ListenAndServeTLS(fmt.Sprintf("0.0.0.0:%s", port), certFile, keyFile) -}