Skip to content

Commit

Permalink
DXCDT-316: More self-documenting reveal secret flag (#591)
Browse files Browse the repository at this point in the history
Co-authored-by: Will Vedder <[email protected]>
Co-authored-by: Sergiu Ghitea <[email protected]>
Co-authored-by: Sergiu Ghitea <[email protected]>
  • Loading branch information
4 people authored Jan 10, 2023
1 parent fa6e987 commit 244dda5
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 37 deletions.
4 changes: 2 additions & 2 deletions docs/auth0_apps_create.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ auth0 apps create [flags]
auth0 apps create --name myapp
auth0 apps create --name myapp --description <description>
auth0 apps create --name myapp --description <description> --type [native|spa|regular|m2m]
auth0 apps create --name myapp --description <description> --type [native|spa|regular|m2m] --reveal
auth0 apps create --name myapp --description <description> --type [native|spa|regular|m2m] --reveal-secrets
auth0 apps create -n myapp -d <description> -t [native|spa|regular|m2m] -r --json
```

Expand All @@ -37,7 +37,7 @@ auth0 apps create [flags]
-l, --logout-urls strings Comma-separated list of URLs that are valid to redirect to after logout from Auth0. Wildcards are allowed for subdomains.
-n, --name string Name of the application.
-o, --origins strings Comma-separated list of URLs allowed to make requests from JavaScript to Auth0 API (typically used with CORS). By default, all your callback URLs will be allowed. This field allows you to enter other origins if necessary. You can also use wildcards at the subdomain level (e.g., https://*.contoso.com). Query strings and hash information are not taken into account when validating these URLs.
-r, --reveal Display the Client Secret as part of the command output.
-r, --reveal-secrets Display the application secrets ('signing_keys', 'client_secret') as part of the command output.
-t, --type string Type of application:
- native: mobile, desktop, CLI and smart device apps running natively.
- spa (single page application): a JavaScript front-end app that uses an API.
Expand Down
10 changes: 5 additions & 5 deletions docs/auth0_apps_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ auth0 apps list [flags]
```
auth0 apps list
auth0 apps ls
auth0 apps list --reveal
auth0 apps list --reveal --number 100
auth0 apps list --reveal-secrets
auth0 apps list --reveal-secrets --number 100
auth0 apps ls -r -n 100 --json
```


## Flags

```
--json Output in json format.
-n, --number int Number of apps to retrieve (default 50)
-r, --reveal Display the Client Secret as part of the command output.
--json Output in json format.
-n, --number int Number of apps to retrieve (default 50)
-r, --reveal-secrets Display the application secrets ('signing_keys', 'client_secret') as part of the command output.
```


Expand Down
8 changes: 4 additions & 4 deletions docs/auth0_apps_show.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ auth0 apps show [flags]
```
auth0 apps show
auth0 apps show <app-id>
auth0 apps show <app-id> --reveal
auth0 apps show <app-id> --reveal --json
auth0 apps show <app-id> --reveal-secrets
auth0 apps show <app-id> -r --json
```


## Flags

```
--json Output in json format.
-r, --reveal Display the Client Secret as part of the command output.
--json Output in json format.
-r, --reveal-secrets Display the application secrets ('signing_keys', 'client_secret') as part of the command output.
```


Expand Down
4 changes: 2 additions & 2 deletions docs/auth0_apps_update.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ auth0 apps update [flags]
auth0 apps update <app-id> --name myapp
auth0 apps update <app-id> --name myapp --description <description>
auth0 apps update <app-id> --name myapp --description <description> --type [native|spa|regular|m2m]
auth0 apps update <app-id> --name myapp --description <description> --type [native|spa|regular|m2m] --reveal
auth0 apps update <app-id> --name myapp --description <description> --type [native|spa|regular|m2m] --reveal-secrets
auth0 apps update <app-id> -n myapp -d <description> -t [native|spa|regular|m2m] -r --json
```

Expand All @@ -37,7 +37,7 @@ auth0 apps update [flags]
-l, --logout-urls strings Comma-separated list of URLs that are valid to redirect to after logout from Auth0. Wildcards are allowed for subdomains.
-n, --name string Name of the application.
-o, --origins strings Comma-separated list of URLs allowed to make requests from JavaScript to Auth0 API (typically used with CORS). By default, all your callback URLs will be allowed. This field allows you to enter other origins if necessary. You can also use wildcards at the subdomain level (e.g., https://*.contoso.com). Query strings and hash information are not taken into account when validating these URLs.
-r, --reveal Display the Client Secret as part of the command output.
-r, --reveal-secrets Display the application secrets ('signing_keys', 'client_secret') as part of the command output.
-t, --type string Type of application:
- native: mobile, desktop, CLI and smart device apps running natively.
- spa (single page application): a JavaScript front-end app that uses an API.
Expand Down
46 changes: 23 additions & 23 deletions internal/cli/apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,11 @@ var (
Help: "List of grant types supported for this application. Can include code, implicit, refresh-token, credentials, password, password-realm, mfa-oob, mfa-otp, mfa-recovery-code, and device-code.",
IsRequired: false,
}
reveal = Flag{
revealSecrets = Flag{
Name: "Reveal",
LongForm: "reveal",
LongForm: "reveal-secrets",
ShortForm: "r",
Help: "Display the Client Secret as part of the command output.",
Help: "Display the application secrets ('signing_keys', 'client_secret') as part of the command output.",
}
number = Flag{
Name: "Number",
Expand Down Expand Up @@ -200,8 +200,8 @@ func useAppCmd(cli *cli) *cobra.Command {

func listAppsCmd(cli *cli) *cobra.Command {
var inputs struct {
Reveal bool
Number int
RevealSecrets bool
Number int
}

cmd := &cobra.Command{
Expand All @@ -212,8 +212,8 @@ func listAppsCmd(cli *cli) *cobra.Command {
Long: "List your existing applications. To create one, run: `auth0 apps create`.",
Example: ` auth0 apps list
auth0 apps ls
auth0 apps list --reveal
auth0 apps list --reveal --number 100
auth0 apps list --reveal-secrets
auth0 apps list --reveal-secrets --number 100
auth0 apps ls -r -n 100 --json`,
RunE: func(cmd *cobra.Command, args []string) error {
list, err := getWithPagination(
Expand All @@ -237,22 +237,22 @@ func listAppsCmd(cli *cli) *cobra.Command {
for _, item := range list {
typedList = append(typedList, item.(*management.Client))
}
cli.renderer.ApplicationList(typedList, inputs.Reveal)
cli.renderer.ApplicationList(typedList, inputs.RevealSecrets)
return nil
},
}

cmd.Flags().BoolVar(&cli.json, "json", false, "Output in json format.")
reveal.RegisterBool(cmd, &inputs.Reveal, false)
revealSecrets.RegisterBool(cmd, &inputs.RevealSecrets, false)
number.RegisterInt(cmd, &inputs.Number, defaultPageSize)

return cmd
}

func showAppCmd(cli *cli) *cobra.Command {
var inputs struct {
ID string
Reveal bool
ID string
RevealSecrets bool
}

cmd := &cobra.Command{
Expand All @@ -262,8 +262,8 @@ func showAppCmd(cli *cli) *cobra.Command {
Long: "Display the name, description, app type, and other information about an application.",
Example: ` auth0 apps show
auth0 apps show <app-id>
auth0 apps show <app-id> --reveal
auth0 apps show <app-id> --reveal --json`,
auth0 apps show <app-id> --reveal-secrets
auth0 apps show <app-id> -r --json`,
RunE: func(cmd *cobra.Command, args []string) error {
if len(args) == 0 {
err := appID.Pick(cmd, &inputs.ID, cli.appPickerOptions)
Expand All @@ -284,13 +284,13 @@ func showAppCmd(cli *cli) *cobra.Command {
return fmt.Errorf("Unable to load application: %w", err)
}

cli.renderer.ApplicationShow(a, inputs.Reveal)
cli.renderer.ApplicationShow(a, inputs.RevealSecrets)
return nil
},
}

cmd.Flags().BoolVar(&cli.json, "json", false, "Output in json format.")
reveal.RegisterBool(cmd, &inputs.Reveal, false)
revealSecrets.RegisterBool(cmd, &inputs.RevealSecrets, false)

return cmd
}
Expand Down Expand Up @@ -357,7 +357,7 @@ func createAppCmd(cli *cli) *cobra.Command {
AllowedLogoutURLs []string
AuthMethod string
Grants []string
Reveal bool
RevealSecrets bool
}
var oidcConformant = true
var algorithm = "RS256"
Expand All @@ -373,7 +373,7 @@ func createAppCmd(cli *cli) *cobra.Command {
auth0 apps create --name myapp
auth0 apps create --name myapp --description <description>
auth0 apps create --name myapp --description <description> --type [native|spa|regular|m2m]
auth0 apps create --name myapp --description <description> --type [native|spa|regular|m2m] --reveal
auth0 apps create --name myapp --description <description> --type [native|spa|regular|m2m] --reveal-secrets
auth0 apps create -n myapp -d <description> -t [native|spa|regular|m2m] -r --json`,
RunE: func(cmd *cobra.Command, args []string) error {
// Prompt for app name
Expand Down Expand Up @@ -478,7 +478,7 @@ func createAppCmd(cli *cli) *cobra.Command {
}

// Render result
cli.renderer.ApplicationCreate(a, inputs.Reveal)
cli.renderer.ApplicationCreate(a, inputs.RevealSecrets)

return nil
},
Expand All @@ -494,7 +494,7 @@ func createAppCmd(cli *cli) *cobra.Command {
appLogoutURLs.RegisterStringSlice(cmd, &inputs.AllowedLogoutURLs, nil)
appAuthMethod.RegisterString(cmd, &inputs.AuthMethod, "")
appGrants.RegisterStringSlice(cmd, &inputs.Grants, nil)
reveal.RegisterBool(cmd, &inputs.Reveal, false)
revealSecrets.RegisterBool(cmd, &inputs.RevealSecrets, false)

return cmd
}
Expand All @@ -511,7 +511,7 @@ func updateAppCmd(cli *cli) *cobra.Command {
AllowedLogoutURLs []string
AuthMethod string
Grants []string
Reveal bool
RevealSecrets bool
}

cmd := &cobra.Command{
Expand All @@ -526,7 +526,7 @@ func updateAppCmd(cli *cli) *cobra.Command {
auth0 apps update <app-id> --name myapp
auth0 apps update <app-id> --name myapp --description <description>
auth0 apps update <app-id> --name myapp --description <description> --type [native|spa|regular|m2m]
auth0 apps update <app-id> --name myapp --description <description> --type [native|spa|regular|m2m] --reveal
auth0 apps update <app-id> --name myapp --description <description> --type [native|spa|regular|m2m] --reveal-secrets
auth0 apps update <app-id> -n myapp -d <description> -t [native|spa|regular|m2m] -r --json`,
RunE: func(cmd *cobra.Command, args []string) error {
var current *management.Client
Expand Down Expand Up @@ -688,7 +688,7 @@ func updateAppCmd(cli *cli) *cobra.Command {
}

// Render result
cli.renderer.ApplicationUpdate(a, inputs.Reveal)
cli.renderer.ApplicationUpdate(a, inputs.RevealSecrets)

return nil
},
Expand All @@ -704,7 +704,7 @@ func updateAppCmd(cli *cli) *cobra.Command {
appLogoutURLs.RegisterStringSliceU(cmd, &inputs.AllowedLogoutURLs, nil)
appAuthMethod.RegisterStringU(cmd, &inputs.AuthMethod, "")
appGrants.RegisterStringSliceU(cmd, &inputs.Grants, nil)
reveal.RegisterBool(cmd, &inputs.Reveal, false)
revealSecrets.RegisterBool(cmd, &inputs.RevealSecrets, false)

return cmd
}
Expand Down
2 changes: 1 addition & 1 deletion internal/cli/apps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func TestAppsListCmd(t *testing.T) {
},
{
name: "reveal secrets",
args: []string{"--reveal"},
args: []string{"--reveal-secrets"},
assertOutput: func(t testing.TB, out string) {
expectTable(t, out,
[]string{"CLIENT ID", "NAME", "TYPE", "CLIENT SECRET"},
Expand Down

0 comments on commit 244dda5

Please sign in to comment.