-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8458b54
commit 58ae0fc
Showing
4 changed files
with
666 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
diff --git a/ziti/cmd/edge/quickstart.go b/ziti/cmd/edge/quickstart.go | ||
index d0ed9b16a..38df46cb9 100644 | ||
--- a/ziti/cmd/edge/quickstart.go | ||
+++ b/ziti/cmd/edge/quickstart.go | ||
@@ -24,6 +24,7 @@ import ( | ||
edgeSubCmd "github.com/openziti/ziti/controller/subcmd" | ||
"github.com/openziti/ziti/ziti/cmd/create" | ||
"github.com/openziti/ziti/ziti/cmd/helpers" | ||
+ "github.com/openziti/ziti/ziti/cmd/login" | ||
"github.com/openziti/ziti/ziti/cmd/pki" | ||
"github.com/openziti/ziti/ziti/constants" | ||
controller2 "github.com/openziti/ziti/ziti/controller" | ||
@@ -214,7 +215,7 @@ func (o *QuickstartOpts) run(ctx context.Context) { | ||
|
||
erYaml := o.Home + "/" + routerName + ".yaml" | ||
if !o.AlreadyInitialized { | ||
- loginCmd := NewLoginCmd(o.out, o.errOut) | ||
+ loginCmd := login.NewLoginCmd(o.out, o.errOut) | ||
loginCmd.SetArgs([]string{ | ||
ctrlUrl, | ||
fmt.Sprintf("--username=%s", o.Username), | ||
diff --git a/ziti/cmd/edge/root.go b/ziti/cmd/edge/root.go | ||
index a8e16155a..daeaf0138 100644 | ||
--- a/ziti/cmd/edge/root.go | ||
+++ b/ziti/cmd/edge/root.go | ||
@@ -20,6 +20,7 @@ import ( | ||
"context" | ||
"github.com/openziti/ziti/ziti/cmd/common" | ||
cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" | ||
+ "github.com/openziti/ziti/ziti/cmd/login" | ||
"github.com/openziti/ziti/ziti/util" | ||
"io" | ||
|
||
@@ -35,8 +36,8 @@ func NewCmdEdge(out io.Writer, errOut io.Writer, p common.OptionsProvider) *cobr | ||
|
||
cmd.AddCommand(newCreateCmd(out, errOut)) | ||
cmd.AddCommand(newDeleteCmd(out, errOut)) | ||
- cmd.AddCommand(NewLoginCmd(out, errOut)) | ||
- cmd.AddCommand(newLogoutCmd(out, errOut)) | ||
+ cmd.AddCommand(login.NewLoginCmd(out, errOut)) | ||
+ cmd.AddCommand(login.NewLogoutCmd(out, errOut)) | ||
cmd.AddCommand(newUseCmd(out, errOut)) | ||
cmd.AddCommand(newListCmd(out, errOut)) | ||
cmd.AddCommand(newUpdateCmd(out, errOut)) | ||
diff --git a/ziti/cmd/verify/ops_verify_traffic.go b/ziti/cmd/verify/ops_verify_traffic.go | ||
index ebd376b4c..18fa12234 100644 | ||
--- a/ziti/cmd/verify/ops_verify_traffic.go | ||
+++ b/ziti/cmd/verify/ops_verify_traffic.go | ||
@@ -22,8 +22,10 @@ import ( | ||
"fmt" | ||
"github.com/michaelquigley/pfxlog" | ||
"github.com/openziti/foundation/v2/term" | ||
+ "github.com/openziti/ziti/ziti/util" | ||
"github.com/sirupsen/logrus" | ||
"net" | ||
+ "net/http" | ||
"os" | ||
"strings" | ||
"sync" | ||
@@ -67,6 +69,34 @@ func NewVerifyTraffic() *cobra.Command { | ||
Short: "Verifies traffic", | ||
Long: "A tool to verify traffic can flow over the overlay properly. You must be authenticated to use this tool.", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
+ | ||
+ //loginOpts := login.LoginOptions{ | ||
+ // Options: api.Options{ | ||
+ // CommonOptions: common.CommonOptions{ | ||
+ // Out: os.Stdout, | ||
+ // Err: os.Stderr, | ||
+ // }, | ||
+ // }, | ||
+ // Username: t.user, | ||
+ // PromptForPass: false, | ||
+ // //Password: t.pass, | ||
+ // //Token: "", | ||
+ // //CaCert: "", | ||
+ // //ReadOnly: false, | ||
+ // //Yes: false, | ||
+ // //IgnoreConfig: false, | ||
+ // //ClientCert: "", | ||
+ // //ClientKey: "", | ||
+ // //ExtJwt: "", | ||
+ // //File: "", | ||
+ // //FileCertCreds: nil, | ||
+ //} | ||
+ ////authErr := loginOpts.AuthCli() | ||
+ ////if authErr != nil { | ||
+ //// logrus.Fatal(authErr) | ||
+ ////} | ||
+ | ||
+ | ||
logLvl := logrus.InfoLevel | ||
if t.verbose { | ||
logLvl = logrus.DebugLevel | ||
@@ -85,7 +115,7 @@ func NewVerifyTraffic() *cobra.Command { | ||
if t.mode == "" { | ||
t.mode = "both" | ||
} | ||
- | ||
+ | ||
t.svcName = t.prefix + ".verify-traffic" | ||
|
||
t.serverIdName = t.prefix + ".server" | ||
@@ -315,7 +345,53 @@ func (t *traffic) newMgmtClient() (*rest_management_api_client.ZitiEdgeManagemen | ||
for _, ca := range caCerts { | ||
caPool.AddCert(ca) | ||
} | ||
- return rest_util.NewEdgeManagementClientWithUpdb(t.user, t.pass, ctrlAddress, caPool) | ||
+ | ||
+ r1, _, loadErr := util.LoadRestClientConfig() | ||
+ if loadErr != nil { | ||
+ log.Fatal(loadErr) | ||
+ } | ||
+ token := r1.EdgeIdentities[r1.Default].Token | ||
+ | ||
+ restClientIdentity, err := util.LoadSelectedIdentity() | ||
+ if err != nil { | ||
+ log.Fatal(err) | ||
+ } | ||
+ | ||
+ baseUrl, err := restClientIdentity.GetBaseUrlForApi(util.EdgeAPI) | ||
+ if err != nil { | ||
+ log.Fatal(err) | ||
+ } | ||
+ | ||
+ req, err := util.NewRequest(restClientIdentity, 10, false) | ||
+ if err != nil { | ||
+ log.Fatal(err) | ||
+ } | ||
+ queryUrl := baseUrl + "/" | ||
+ | ||
+ //if len(params) > 0 { | ||
+ // queryUrl += "?" + params.Encode() | ||
+ //} | ||
+ | ||
+ resp, err := req.Get(queryUrl) | ||
+ if err != nil { | ||
+ log.Fatal(err) | ||
+ } | ||
+ | ||
+ if resp.StatusCode() != http.StatusOK { | ||
+ | ||
+ } | ||
+ | ||
+ auth := rest_util.NewAuthenticatorAuthHeader(token) | ||
+ params := auth.Params() | ||
+ | ||
+ resp, err := client.Authentication.Authenticate(params) | ||
+ if err != nil { | ||
+ return nil, err | ||
+ } | ||
+ | ||
+ return rest_util.NewEdgeManagementClientWithAuthenticator(auth, ctrlAddress) | ||
+ //ttpClient *http.Client, apiAddress string, apiSessionToken string | ||
+ //return rest_util.NewEdgeManagementClientWithUpdb(t.user, t.pass, ctrlAddress, caPool) | ||
} | ||
|
||
func createIdentity(client *rest_management_api_client.ZitiEdgeManagement, name string, roleAttributes rest_model.Attributes) *identity.CreateIdentityCreated { |
Oops, something went wrong.