Documentation ¶
Overview ¶
Copyright (C) 2020 Serge ALEXANDRE
This file is part of koobind project ¶
koobind is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
koobind is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with koobind. If not, see <http://www.gnu.org/licenses/>.
Copyright (C) 2020 Serge ALEXANDRE This file is part of koobind project koobind is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. koobind is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with koobind. If not, see <http://www.gnu.org/licenses/>.
Copyright (C) 2020 Serge ALEXANDRE ¶
This file is part of koobind project ¶
koobind is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
koobind is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with koobind. If not, see <http://www.gnu.org/licenses/>.
Copyright (C) 2020 Serge ALEXANDRE ¶
This file is part of koobind project ¶
koobind is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
koobind is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with koobind. If not, see <http://www.gnu.org/licenses/>.
Copyright (C) 2020 Serge ALEXANDRE ¶
This file is part of koobind project ¶
koobind is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
koobind is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with koobind. If not, see <http://www.gnu.org/licenses/>.
Copyright (C) 2020 Serge ALEXANDRE This file is part of koobind project koobind is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. koobind is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with koobind. If not, see <http://www.gnu.org/licenses/>.
Copyright (C) 2020 Serge ALEXANDRE ¶
This file is part of koobind project ¶
koobind is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
koobind is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with koobind. If not, see <http://www.gnu.org/licenses/>.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var AuthCmd = &cobra.Command{ Use: "auth", Short: "To be used as client-go exec plugin", Hidden: true, Run: func(cmd *cobra.Command, args []string) { common.InitHttpConnection() tokenBag := common.RetrieveTokenBag() if tokenBag == nil { tokenBag = common.DoLoginSilently("", "") } ec := ExecCredential{ ApiVersion: "client.authentication.k8s.io/v1beta1", Kind: "ExecCredential", } if tokenBag == nil { } else { ec.Status.Token = tokenBag.Token } err := json.NewEncoder(os.Stdout).Encode(ec) if err != nil { panic(err) } }, }
var HashCmd = &cobra.Command{ Use: "hash", Short: "Provided password hash, for use in config file", Run: func(cmd *cobra.Command, args []string) { if hash_password == "" { hash_password = inputPassword("Password:") password2 := inputPassword("Confirm password:") if hash_password != password2 { fmt.Printf("Passwords did not match!\n") return } } hash, err := bcrypt.GenerateFromPassword([]byte(hash_password), bcrypt.DefaultCost) if err != nil { panic(err) } fmt.Printf("%s\n", string(hash)) }, }
var LoginCmd = &cobra.Command{ Use: "login", Short: "Logout and get a new token", Run: func(cmd *cobra.Command, args []string) { common.InitHttpConnection() internal.DeleteTokenBag(common.Context) tokenBag := common.DoLogin(login, login_password) if tokenBag == nil { os.Exit(3) } }, }
var LogoutCmd = &cobra.Command{ Use: "logout", Short: "Clear local token", Run: func(cmd *cobra.Command, args []string) { internal.DeleteTokenBag(common.Context) fmt.Printf("Bye!\n") }, }
var PasswordCmd = &cobra.Command{ Use: "password", Short: "Change current user password", Run: func(cmd *cobra.Command, args []string) { common.InitHttpConnection() tokenBag := common.RetrieveTokenBag() if tokenBag == nil { _, _ = fmt.Fprintf(os.Stderr, "Not logged in currently\n") return } if oldPassword == "" { oldPassword = inputPassword("Old password:") } if newPassword == "" { newPassword = inputPasswordWithConfirm() if newPassword == "" { _, _ = fmt.Fprintf(os.Stderr, "Too many failure !!!\n") return } } changePasswordRequest := proto.ChangePasswordRequest{ OldPassword: oldPassword, NewPassword: newPassword, Client: common.Config.Client, } body, err := json.Marshal(changePasswordRequest) response, err := common.HttpConnection.Do("POST", proto.ChangePasswordUrlPath, &internal.HttpAuth{Token: tokenBag.Token}, bytes.NewBuffer(body)) if err != nil { panic(err) } if response.StatusCode == http.StatusOK { fmt.Printf("Password changed successfully.\n") return } else { common.PrintHttpResponseMessage(response) os.Exit(internal.ReturnCodeFromStatusCode(response.StatusCode)) } }, }
var VersionCmd = &cobra.Command{ Use: "version", Short: "Display current version", Run: func(cmd *cobra.Command, args []string) { fmt.Printf("Version %s\n", version) }, }
var WhoamiCmd = &cobra.Command{ Use: "whoami", Short: "Display current logged user, if any", Run: func(cmd *cobra.Command, args []string) { common.InitHttpConnection() tokenBag := common.RetrieveTokenBag() if tokenBag != nil { tw := new(tabwriter.Writer) tw.Init(os.Stdout, 2, 4, 3, ' ', 0) if displayToken { _, _ = fmt.Fprintf(tw, "USER\tID\tGROUPS\tTOKEN") _, _ = fmt.Fprintf(tw, "\n%s\t%s\t%s\t%s", tokenBag.Username, tokenBag.Uid, strings.Join(tokenBag.Groups, ","), tokenBag.Token) } else { _, _ = fmt.Fprintf(tw, "USER\tID\tGROUPS") _, _ = fmt.Fprintf(tw, "\n%s\t%s\t%s", tokenBag.Username, tokenBag.Uid, strings.Join(tokenBag.Groups, ",")) } _, _ = fmt.Fprintf(tw, "\n") _ = tw.Flush() } else { fmt.Printf("Nobody! (Not logged)\n") os.Exit(3) } }, }
Functions ¶
This section is empty.