Skip to content

Commit

Permalink
refinements to original add-verify-ext-jwt-oidc
Browse files Browse the repository at this point in the history
  • Loading branch information
dovholuknf committed Jan 29, 2025
1 parent ec06ce2 commit 48ef281
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 24 deletions.
3 changes: 3 additions & 0 deletions internal/cobra/cobra-utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,7 @@ Common flags for all commands:
Use "{{.CommandPath}} [command] --help" for more information about a command.
`)
cmd.SetUsageFunc(func(c *cobra.Command) error {
return cmd.Help()
})
}
28 changes: 5 additions & 23 deletions ziti/cmd/edge/ext-jwt-signer/oidc/oidc.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ import (
"github.com/openziti/ziti/internal"
ziticobra "github.com/openziti/ziti/internal/cobra"
"github.com/openziti/ziti/internal/rest/client"
"github.com/openziti/ziti/ziti/cmd/api"
"github.com/openziti/ziti/ziti/cmd/edge"
)

Expand Down Expand Up @@ -277,6 +276,10 @@ func NewOidcVerificationCmd(out io.Writer, errOut io.Writer, initialContext cont
Short: "test an external JWT signer for OIDC auth",
Long: "tests and verifies an external JWT signer is configured correctly to authenticate using OIDC",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
// Force display of the usage template
return cmd.Usage()
},
Run: func(cmd *cobra.Command, args []string) {
logLvl := logrus.InfoLevel
if opts.Verbose {
Expand Down Expand Up @@ -396,28 +399,7 @@ func NewOidcVerificationCmd(out io.Writer, errOut io.Writer, initialContext cont
cmd.Flags().StringVar(&opts.ControllerUrl, "controller-url", "", "The url of the controller")
cmd.Flags().StringSliceVarP(&opts.additionalScopes, "additional-scopes", "s", []string{}, "List of additional scopes to add")

l := ziticobra.GetFlagsForAnnotation(cmd, edge.LoginFlagKey)
c := ziticobra.GetFlagsForAnnotation(cmd, api.CommonFlagKey)
u := ziticobra.GetFlagsWithoutAnnotations(cmd, edge.LoginFlagKey, api.CommonFlagKey)
cmd.SetHelpTemplate(`{{.Long}}
Usage:
{{.UseLine}}
Available Commands:
{{range .Commands}}{{if (or .IsAvailableCommand (eq .Name "help"))}}
{{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}
Flags:
` + u + `
Flags related to logging in:
` + l + `
Common flags for all commands:
` + c + `
Use "{{.CommandPath}} [command] --help" for more information about a command.
`)

ziticobra.SetHelpTemplate(cmd)
return cmd
}

Expand Down
2 changes: 1 addition & 1 deletion ziti/cmd/edge/ext-jwt-signer/verify-ext-jwt-signer.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (

func NewVerifyExtJwtSignerCmd(out io.Writer, errOut io.Writer, initialContext context.Context) *cobra.Command {
cmd := &cobra.Command{
Use: "verify-ext-auth",
Use: "verify-ext-jwt-signer",
Short: "test if an external JWT signer is correctly configured",
Long: "tests and verifies an external JWT signer is configured correctly",
}
Expand Down

0 comments on commit 48ef281

Please sign in to comment.