Merge pull request #729 from openziti/adds.re-enroll.cli

adds CLI support for authenticators/enrollments/re-enrollment
This commit is contained in:
Andrew
2022-05-24 10:14:22 -04:00
committed by GitHub
9 changed files with 406 additions and 158 deletions
+30
View File
@@ -1,3 +1,33 @@
# Release 0.25.10
## What's New
- Edge
- N/A
- Fabric
- N/A
- Ziti CLI
- CLI support for enrollments/authenticators/re-enrollment
- SDK Golang
- N/A
## Ziti CLI
### CLI support for enrollments/authenticators/re-enrollment
The CLI has been augmented to support the following commands:
- `ziti edge list authenticators` - to generically list existing authenticators
- `ziti edge list enrollments` - to generically list existing enrollments
- `ziti edge delete enrollment <id>` - to generically delete existing enrollments
- `ziti edge delete authenticator <id>` - to generically delete existing authenticator
- `ziti edge create enrollment ott ...` - to create a new one-time-token enrollment for an existing identity
- `ziti edge create enrollment ottca ...` - to create a new one-time-token enrollment for an existing identity for a 3rd party CA issued certificate
- `ziti edge create enrollment updb ...` - to create a new updb (username/password) enrollment for an existing identity
These commands, specifically the enrollment related ones, can be used to re-enroll existing identities. See the 0.25.9 changeFor all arguments and options, please see their CLI related `-h`.
Also note that the `ziti edge delete authenticator updb` command has been supplanted by `ziti edge edge authenticator <authenticator id>`
# Release 0.25.9
## What's New
+7 -6
View File
@@ -21,13 +21,13 @@ require (
github.com/jedib0t/go-pretty/v6 v6.2.4
github.com/keybase/go-ps v0.0.0-20190827175125-91aafc93ba19
github.com/michaelquigley/pfxlog v0.6.9
github.com/openziti/channel v0.18.36
github.com/openziti/edge v0.21.217
github.com/openziti/fabric v0.17.136
github.com/openziti/channel v0.18.37
github.com/openziti/edge v0.21.222
github.com/openziti/fabric v0.17.137
github.com/openziti/foundation v0.17.25
github.com/openziti/sdk-golang v0.16.69
github.com/openziti/sdk-golang v0.16.70
github.com/openziti/storage v0.1.5
github.com/openziti/transport/v2 v2.0.1
github.com/openziti/transport/v2 v2.0.2
github.com/openziti/ziti-db-explorer v1.1.1
github.com/pborman/uuid v1.2.0
github.com/pkg/errors v0.9.1
@@ -41,7 +41,7 @@ require (
github.com/stretchr/testify v1.7.1
github.com/valyala/fasttemplate v1.2.1
go.etcd.io/bbolt v1.3.6
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd
golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4
google.golang.org/grpc v1.42.0
google.golang.org/protobuf v1.28.0
gopkg.in/AlecAivazis/survey.v1 v1.8.7
@@ -120,6 +120,7 @@ require (
github.com/oklog/ulid v1.3.1 // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/openziti/dilithium v0.3.3 // indirect
github.com/openziti/x509-claims v1.0.2 // indirect
github.com/orcaman/concurrent-map v0.0.0-20210106121528-16402b402231 // indirect
github.com/parallaxsecond/parsec-client-go v0.0.0-20220111122524-cb78842db373 // indirect
github.com/pelletier/go-toml v1.9.4 // indirect
+14 -11
View File
@@ -633,22 +633,24 @@ github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+
github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc=
github.com/openzipkin/zipkin-go v0.1.1/go.mod h1:NtoC/o8u3JlF1lSlyPNswIbeQH9bJTmOf0Erfk+hxe8=
github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw=
github.com/openziti/channel v0.18.36 h1:x7TgEpw3ecIpginDsqAMGBTdhtCdMx2BR9m9wzXmZhY=
github.com/openziti/channel v0.18.36/go.mod h1:97VgqsQ8BV9KZ9zKiaeCM9rTOn2Kft6yaS1c+fdec9A=
github.com/openziti/channel v0.18.37 h1:a6PKCcKUZCidAlAehxpVRDrFrKOS2JVnuDqDhbZUTw4=
github.com/openziti/channel v0.18.37/go.mod h1:6ZwVC+xSY83eETr8lR/8Ic1yuaPkKYQqj6TsVwkbm/0=
github.com/openziti/dilithium v0.3.3 h1:PLgQ6PMNLSTzCFbX/h98cmudgz/cU6TmjdSv5NAPD8k=
github.com/openziti/dilithium v0.3.3/go.mod h1:vsCjI2AU/hon9e+dLhUFbCNGesJDj2ASgkySOcpmvjo=
github.com/openziti/edge v0.21.217 h1:ifbZlfGAt032yyBXorxAuYWq+zZQge3HLh/haPT6JQ0=
github.com/openziti/edge v0.21.217/go.mod h1:3k4j2+jd5e8F681xleiW5rc0oTAvSMzJuI1hnAc8mYw=
github.com/openziti/fabric v0.17.136 h1:JcK+oTDv2Bg7vgJwAAYCqd5G1lxzwZMzlTqsk9UHfnY=
github.com/openziti/fabric v0.17.136/go.mod h1:6Yy/kSr3zl//g2RBAlXn/hrlMdG1IhzPlPf3SsCK1pA=
github.com/openziti/edge v0.21.222 h1:PG/sYcWoX4hjn8aUZoHGJ7TTuJNqJEqfGVL9N+Os66M=
github.com/openziti/edge v0.21.222/go.mod h1:hp48iOCDm2snkeXgDZPGcpvM5o63Cn4yW1ZApHsq190=
github.com/openziti/fabric v0.17.137 h1:3GPavC0qrGOQ70B+fEt3VHaFEBSd9FZG8fbglLhysq4=
github.com/openziti/fabric v0.17.137/go.mod h1:91EbauR7VOgADLzDOSuWxfhgzAJSqvRQdZ7XwPixhuc=
github.com/openziti/foundation v0.17.25 h1:s7E7LIYHGeJQQqmQI1uLA2Ml3L2dgGbeTN+rD6Woo78=
github.com/openziti/foundation v0.17.25/go.mod h1:YMalQrbDP3S5ptEcob4v3F+pyCngabaG/hQVoT9Pcxo=
github.com/openziti/sdk-golang v0.16.69 h1:EnlDeNAK0nFcM8MKU5lcDJZ/p/xGT2oDtzJ6kmn6RrA=
github.com/openziti/sdk-golang v0.16.69/go.mod h1:z83nTE+webbbRrgtvvEdr1sQWxaoC+jbeVmKW1c4JJI=
github.com/openziti/sdk-golang v0.16.70 h1:hF7Bk+48zkg4ZwWb9Xrky0eE8d6HwJ092a5XclXISMc=
github.com/openziti/sdk-golang v0.16.70/go.mod h1:QTR5a37mtyKRsl0r7NodmrmdYCrdqJv7zqShFwccoJs=
github.com/openziti/storage v0.1.5 h1:Q13TaO7El1v9CJoGZjhLPdS/T/s897TGKegiWov3J4M=
github.com/openziti/storage v0.1.5/go.mod h1:VvubFzlkqzxFJnQV+QawR++OhDQ1l283S7b2J8BPKmk=
github.com/openziti/transport/v2 v2.0.1 h1:zLE5o1nUJrz+dVHz+smdswtLQlwyJa0OzZ15+2sPwAk=
github.com/openziti/transport/v2 v2.0.1/go.mod h1:GeXnw3NDybPLKd8g3IMpXkYo8G8VXu+5+MT5g4BpmQY=
github.com/openziti/transport/v2 v2.0.2 h1:w01etEkf5V0tkgtd9Z0MOTGz+oH8yeEbXWMn38y/uP8=
github.com/openziti/transport/v2 v2.0.2/go.mod h1:DLW9bvW/QL7uCaGmy5s5rdQoKgFKfu/JJWPcc/syqSE=
github.com/openziti/x509-claims v1.0.2 h1:PSv/xRfejIAcPc16A902k08rSBs3R8bjtL4qq6WEwCI=
github.com/openziti/x509-claims v1.0.2/go.mod h1:Z0WIpBm6c4ecrpRKrou6Gk2wrLWxJO/+tuUwKh8VewE=
github.com/openziti/ziti-db-explorer v1.1.1 h1:G0eoTby+aIjjt5TxEfR+FMI2CWd4RvZFjzaIMX2lEBw=
github.com/openziti/ziti-db-explorer v1.1.1/go.mod h1:h76h7Tsb+khb0v+CqYKL6ifUfJbUMjGBFU2IvupfBE4=
github.com/oracle/oci-go-sdk v24.2.0+incompatible/go.mod h1:VQb79nF8Z2cwLkLS35ukwStZIg5F66tcBccjip/j888=
@@ -1003,8 +1005,9 @@ golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96b
golang.org/x/net v0.0.0-20210421230115-4e50805a0758/go.mod h1:72T/g9IO56b78aLF+1Kcs5dz7/ng1VjMUvfKvpfy+jM=
golang.org/x/net v0.0.0-20210726213435-c6fcb2dbf985/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20210928044308-7d9f5e0b762b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd h1:O7DYs+zxREGLKzKoMQrtrEacpb0ZVXA5rIwylE2Xchk=
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 h1:HVyaeDAYux4pnY+D/SiwmLOR36ewZ4iGQIIrtnuCjFA=
golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
+1
View File
@@ -49,6 +49,7 @@ func newCreateCmd(out io.Writer, errOut io.Writer) *cobra.Command {
cmd.AddCommand(newCreateServiceEdgeRouterPolicyCmd(out, errOut))
cmd.AddCommand(newCreateServicePolicyCmd(out, errOut))
cmd.AddCommand(newCreatePostureCheckCmd(out, errOut))
cmd.AddCommand(newCreateEnrollmentCmd(out, errOut))
return cmd
}
+276
View File
@@ -0,0 +1,276 @@
/*
Copyright NetFoundry, Inc.
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
https://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 edge
import (
"context"
"fmt"
"github.com/go-openapi/strfmt"
"github.com/openziti/edge/rest_management_api_client/enrollment"
"github.com/openziti/edge/rest_model"
"github.com/openziti/ziti/ziti/cmd/ziti/cmd/api"
"github.com/openziti/ziti/ziti/cmd/ziti/cmd/common"
cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers"
"github.com/openziti/ziti/ziti/cmd/ziti/util"
"github.com/spf13/cobra"
"io"
"time"
)
func newCreateEnrollmentCmd(out io.Writer, errOut io.Writer) *cobra.Command {
cmd := &cobra.Command{
Use: "enrollment",
}
cmd.AddCommand(newCreateEnrollmentOtt(out, errOut))
cmd.AddCommand(newCreateEnrollmentOttCa(out, errOut))
cmd.AddCommand(newCreateEnrollmentUpdb(out, errOut))
return cmd
}
type createEnrollmentOptions struct {
api.Options
name string
duration int64
}
func newCreateEnrollmentOtt(out io.Writer, errOut io.Writer) *cobra.Command {
options := &createEnrollmentOptions{
Options: api.Options{
CommonOptions: common.CommonOptions{
Out: out,
Err: errOut,
},
},
}
cmd := &cobra.Command{
Use: "ott <identityIdOrName> [-duration <minutes>]",
Short: "creates a one-time-token (ott) enrollment for the given identity",
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
options.Cmd = cmd
options.Args = args
err := runCreateEnrollmentOtt(options)
cmdhelper.CheckErr(err)
},
SuggestFor: []string{},
}
// allow interspersing positional args and flags
cmd.Flags().SetInterspersed(true)
options.AddCommonFlags(cmd)
cmd.Flags().Int64VarP(&options.duration, "duration", "d", 30, "the duration of time the enrollment should valid for")
return cmd
}
func newCreateEnrollmentOttCa(out io.Writer, errOut io.Writer) *cobra.Command {
options := &createEnrollmentOptions{
Options: api.Options{
CommonOptions: common.CommonOptions{
Out: out,
Err: errOut,
},
},
}
cmd := &cobra.Command{
Use: "ottca <identityIdOrName> <caIdOrName> [-duration <minutes>]",
Short: "creates a one-time-token ca (ottca) enrollment for the given identity and ca",
Args: cobra.ExactArgs(2),
Run: func(cmd *cobra.Command, args []string) {
options.Cmd = cmd
options.Args = args
err := runCreateEnrollmentOttCa(options)
cmdhelper.CheckErr(err)
},
SuggestFor: []string{},
}
// allow interspersing positional args and flags
cmd.Flags().SetInterspersed(true)
options.AddCommonFlags(cmd)
cmd.Flags().Int64VarP(&options.duration, "duration", "d", 30, "the duration of time the enrollment should valid for")
return cmd
}
func runCreateEnrollmentOtt(options *createEnrollmentOptions) error {
managementClient, err := util.NewEdgeManagementClient(options)
if err != nil {
return err
}
identityId, err := mapNameToID("identities", options.Args[0], options.Options)
if err != nil {
return err
}
method := rest_model.EnrollmentCreateMethodOtt
expiresAt := strfmt.DateTime(time.Now().Add(time.Duration(options.duration) * time.Minute))
params := &enrollment.CreateEnrollmentParams{
Enrollment: &rest_model.EnrollmentCreate{
ExpiresAt: &expiresAt,
IdentityID: &identityId,
Method: &method,
},
Context: context.Background(),
}
resp, err := managementClient.Enrollment.CreateEnrollment(params, nil)
if err != nil {
return util.WrapIfApiError(err)
}
enrollmentID := resp.GetPayload().Data.ID
if _, err = fmt.Fprintf(options.Out, "%v\n", enrollmentID); err != nil {
panic(err)
}
return err
}
func runCreateEnrollmentOttCa(options *createEnrollmentOptions) error {
managementClient, err := util.NewEdgeManagementClient(options)
if err != nil {
return err
}
identityId, err := mapNameToID("identities", options.Args[0], options.Options)
if err != nil {
return err
}
caId, err := mapNameToID("cas", options.Args[1], options.Options)
if err != nil {
return err
}
method := rest_model.EnrollmentCreateMethodOttca
expiresAt := strfmt.DateTime(time.Now().Add(time.Duration(options.duration) * time.Minute))
params := &enrollment.CreateEnrollmentParams{
Enrollment: &rest_model.EnrollmentCreate{
ExpiresAt: &expiresAt,
IdentityID: &identityId,
Method: &method,
CaID: &caId,
},
Context: context.Background(),
}
resp, err := managementClient.Enrollment.CreateEnrollment(params, nil)
if err != nil {
return util.WrapIfApiError(err)
}
enrollmentID := resp.GetPayload().Data.ID
if _, err = fmt.Fprintf(options.Out, "%v\n", enrollmentID); err != nil {
panic(err)
}
return err
}
func newCreateEnrollmentUpdb(out io.Writer, errOut io.Writer) *cobra.Command {
options := &createEnrollmentOptions{
Options: api.Options{
CommonOptions: common.CommonOptions{
Out: out,
Err: errOut,
},
},
}
cmd := &cobra.Command{
Use: "updb <identityIdOrName> <username> [-duration <minutes>]",
Short: "creates a username password (updb) enrollment for the given identity",
Args: cobra.ExactArgs(2),
Run: func(cmd *cobra.Command, args []string) {
options.Cmd = cmd
options.Args = args
err := runCreateEnrollmentUpdb(options)
cmdhelper.CheckErr(err)
},
SuggestFor: []string{},
}
// allow interspersing positional args and flags
cmd.Flags().SetInterspersed(true)
options.AddCommonFlags(cmd)
cmd.Flags().Int64VarP(&options.duration, "duration", "d", 30, "the duration of time the enrollment should valid for")
return cmd
}
func runCreateEnrollmentUpdb(options *createEnrollmentOptions) error {
managementClient, err := util.NewEdgeManagementClient(options)
if err != nil {
return err
}
identityId, err := mapNameToID("identities", options.Args[0], options.Options)
if err != nil {
return err
}
username := options.Args[1]
method := rest_model.EnrollmentCreateMethodUpdb
expiresAt := strfmt.DateTime(time.Now().Add(time.Duration(options.duration) * time.Minute))
params := &enrollment.CreateEnrollmentParams{
Enrollment: &rest_model.EnrollmentCreate{
ExpiresAt: &expiresAt,
IdentityID: &identityId,
Method: &method,
Username: &username,
},
Context: context.Background(),
}
resp, err := managementClient.Enrollment.CreateEnrollment(params, nil)
if err != nil {
return util.WrapIfApiError(err)
}
enrollmentID := resp.GetPayload().Data.ID
if _, err = fmt.Fprintf(options.Out, "%v\n", enrollmentID); err != nil {
panic(err)
}
return err
}
+3 -2
View File
@@ -52,7 +52,8 @@ func newDeleteCmd(out io.Writer, errOut io.Writer) *cobra.Command {
}
cmd.AddCommand(newDeleteCmdForEntityType("api-session", newOptions()))
cmd.AddCommand(newDeleteAuthenticatorCmd("authenticator", newOptions()))
cmd.AddCommand(newDeleteCmdForEntityType("authenticator", newOptions()))
cmd.AddCommand(newDeleteCmdForEntityType("enrollment", newOptions()))
cmd.AddCommand(newDeleteCmdForEntityType("ca", newOptions()))
cmd.AddCommand(newDeleteCmdForEntityType("config", newOptions()))
cmd.AddCommand(newDeleteCmdForEntityType("config-type", newOptions()))
@@ -119,7 +120,7 @@ func newDeleteWhereCmdForEntityType(entityType string, options *api.Options) *co
func runDeleteEntityOfType(o *api.Options, entityType string) error {
var err error
ids := o.Args
if entityType != "terminators" && entityType != "api-sessions" && entityType != "sessions" {
if entityType != "terminators" && entityType != "api-sessions" && entityType != "sessions" && entityType != "authenticators" && entityType != "enrollments" {
ids, err = mapNamesToIDs(entityType, *o, ids...)
}
if err != nil {
@@ -1,37 +0,0 @@
/*
Copyright NetFoundry, Inc.
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
https://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 edge
import (
"github.com/openziti/ziti/ziti/cmd/ziti/cmd/api"
"github.com/spf13/cobra"
)
func newDeleteAuthenticatorCmd(idType string, options *api.Options) *cobra.Command {
cmd := &cobra.Command{
Use: idType,
Short: "deletes an identity's authenticator managed by the Ziti Edge Controller",
Long: "deletes a identity's authenticator managed by the Ziti Edge Controller",
Args: cobra.ExactArgs(0),
SuggestFor: []string{},
}
cmd.AddCommand(newDeleteAuthenticatorUpdb("updb", options))
return cmd
}
@@ -1,102 +0,0 @@
/*
Copyright NetFoundry, Inc.
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
https://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 edge
import (
"context"
"fmt"
"github.com/openziti/edge/rest_management_api_client/authenticator"
"github.com/openziti/ziti/ziti/cmd/ziti/cmd/api"
"github.com/openziti/ziti/ziti/cmd/ziti/util"
"github.com/spf13/cobra"
)
import cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers"
type deleteUpdbOptions struct {
api.Options
}
func newDeleteAuthenticatorUpdb(idType string, options *api.Options) *cobra.Command {
updbOptions := deleteUpdbOptions{
Options: *options,
}
cmd := &cobra.Command{
Use: idType + " <identityNameOrId>",
Short: "deletes an identity's " + idType + " authenticator managed by the Ziti Edge Controller",
Long: "deletes a identity's " + idType + " authenticator managed by the Ziti Edge Controller",
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
options.Cmd = cmd
options.Args = args
err := runDeleteUpdb(args[0], &updbOptions)
cmdhelper.CheckErr(err)
},
SuggestFor: []string{},
}
// allow interspersing positional args and flags
cmd.Flags().SetInterspersed(true)
return cmd
}
func runDeleteUpdb(idOrName string, options *deleteUpdbOptions) error {
identityId, err := mapIdentityNameToID(idOrName, options.Options)
if err != nil {
return err
}
client, err := util.NewEdgeManagementClient(options)
if err != nil {
return err
}
filter := fmt.Sprintf(`identity="%s" and method="updb"`, identityId)
result, err := client.Authenticator.ListAuthenticators(&authenticator.ListAuthenticatorsParams{
Filter: &filter,
Context: context.Background(),
}, nil)
if err != nil {
return util.WrapIfApiError(err)
}
if len(result.Payload.Data) != 1 {
return fmt.Errorf("incorrect number of results, expected 1, got %d", len(result.Payload.Data))
}
if result.Payload.Data[0].ID == nil {
return fmt.Errorf("authenticator contained a nil id")
}
if *result.Payload.Data[0].ID == "" {
return fmt.Errorf("authenticator contained an empty id")
}
authenticatorId := *result.Payload.Data[0].ID
err = deleteEntityOfType(fmt.Sprintf("authenticators/%s", authenticatorId), "", &options.Options)
if err != nil {
return err
}
return nil
}
+75
View File
@@ -57,11 +57,13 @@ func newListCmd(out io.Writer, errOut io.Writer) *cobra.Command {
}
cmd.AddCommand(newListCmdForEntityType("api-sessions", runListApiSessions, newOptions()))
cmd.AddCommand(newListCmdForEntityType("authenticators", runListAuthenticators, newOptions()))
cmd.AddCommand(newListCmdForEntityType("cas", runListCAs, newOptions()))
cmd.AddCommand(newListCmdForEntityType("config-types", runListConfigTypes, newOptions()))
cmd.AddCommand(newListCmdForEntityType("configs", runListConfigs, newOptions()))
cmd.AddCommand(newListEdgeRoutersCmd(newOptions()))
cmd.AddCommand(newListCmdForEntityType("edge-router-policies", runListEdgeRouterPolicies, newOptions(), "erps"))
cmd.AddCommand(newListCmdForEntityType("enrollments", runListEnrollments, newOptions()))
cmd.AddCommand(newListCmdForEntityType("terminators", runListTerminators, newOptions()))
cmd.AddCommand(newListIdentitiesCmd(newOptions()))
cmd.AddCommand(newListServicesCmd(newOptions()))
@@ -446,6 +448,79 @@ func outputEdgeRouterPolicies(o *api.Options, children []*gabs.Container, paging
return nil
}
func runListAuthenticators(o *api.Options) error {
children, pagingInfo, err := listEntitiesWithOptions("authenticators", o)
if err != nil {
return err
}
return outputAuthenticators(o, children, pagingInfo)
}
func outputAuthenticators(o *api.Options, children []*gabs.Container, pagingInfo *api.Paging) error {
if o.OutputJSONResponse {
return nil
}
t := table.NewWriter()
t.SetStyle(table.StyleRounded)
t.AppendHeader(table.Row{"ID", "Method", "Identity Id", "Identity Name", "Username/Fingerprint", "Ca Id"})
for _, entity := range children {
id, _ := entity.Path("id").Data().(string)
method := entity.Path("method").Data().(string)
identityId := entity.Path("identityId").Data().(string)
identityName := entity.Path("identity.name").Data().(string)
caId := ""
if entity.Exists("caId") {
caId = entity.Path("caId").Data().(string)
}
printOrName := ""
if entity.Exists("username") {
printOrName = entity.Path("username").Data().(string)
} else if entity.Exists("fingerprint") {
printOrName = entity.Path("fingerprint").Data().(string)
}
t.AppendRow(table.Row{id, method, identityId, identityName, printOrName, caId})
}
api.RenderTable(o, t, pagingInfo)
return nil
}
func runListEnrollments(o *api.Options) error {
children, pagingInfo, err := listEntitiesWithOptions("enrollments", o)
if err != nil {
return err
}
return outputEnrollments(o, children, pagingInfo)
}
func outputEnrollments(o *api.Options, children []*gabs.Container, pagingInfo *api.Paging) error {
if o.OutputJSONResponse {
return nil
}
t := table.NewWriter()
t.SetStyle(table.StyleRounded)
t.AppendHeader(table.Row{"ID", "Method", "Identity Id", "Identity Name", "Expires At", "Token", "JWT"})
for _, entity := range children {
id, _ := entity.Path("id").Data().(string)
method := entity.Path("method").Data().(string)
identityId := entity.Path("identityId").Data().(string)
identityName := entity.Path("identity.name").Data().(string)
expiresAt := entity.Path("expiresAt").Data().(string)
token := entity.Path("token").Data().(string)
jwt := "See json"
t.AppendRow(table.Row{id, method, identityId, identityName, expiresAt, token, jwt})
}
api.RenderTable(o, t, pagingInfo)
return nil
}
func runListTerminators(o *api.Options) error {
children, pagingInfo, err := listEntitiesWithOptions("terminators", o)
if err != nil {