From 44613508af7487779af8f0a797390ffdf6281609 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Nov 2023 10:44:33 +0000 Subject: [PATCH 1/4] Bump github.com/auth0/go-auth0 from 1.2.0 to 1.3.0 (#908) Bumps [github.com/auth0/go-auth0](https://github.com/auth0/go-auth0) from 1.2.0 to 1.3.0. - [Release notes](https://github.com/auth0/go-auth0/releases) - [Changelog](https://github.com/auth0/go-auth0/blob/main/CHANGELOG.md) - [Commits](https://github.com/auth0/go-auth0/compare/v1.2.0...v1.3.0) --- updated-dependencies: - dependency-name: github.com/auth0/go-auth0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index c8e27160a..3070443bd 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.20 require ( github.com/AlecAivazis/survey/v2 v2.3.7 github.com/PuerkitoBio/rehttp v1.3.0 - github.com/auth0/go-auth0 v1.2.0 + github.com/auth0/go-auth0 v1.3.0 github.com/briandowns/spinner v1.23.0 github.com/charmbracelet/glamour v0.6.0 github.com/fsnotify/fsnotify v1.7.0 diff --git a/go.sum b/go.sum index 0a663f00d..a6e48e491 100644 --- a/go.sum +++ b/go.sum @@ -18,8 +18,8 @@ github.com/andybalholm/brotli v1.0.5 h1:8uQZIdzKmjc/iuPu7O2ioW48L81FgatrcpfFmiq/ github.com/andybalholm/brotli v1.0.5/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= github.com/apparentlymart/go-textseg/v15 v15.0.0 h1:uYvfpb3DyLSCGWnctWKGj857c6ew1u1fNQOlOtuGxQY= github.com/apparentlymart/go-textseg/v15 v15.0.0/go.mod h1:K8XmNZdhEBkdlyDdvbmmsvpAG721bKi0joRfFdHIWJ4= -github.com/auth0/go-auth0 v1.2.0 h1:pZWzWCWk038jDsItwfqrbuoN37xcNHUClfPzW+rk1ok= -github.com/auth0/go-auth0 v1.2.0/go.mod h1:tLH1Qv816g3dpqituiPNN4ET+YoNtk5++68aRg+MxaA= +github.com/auth0/go-auth0 v1.3.0 h1:46bo0C6HYtsdSj4BEF4j6IaQrSAiUqehwuv+IO3qDJ0= +github.com/auth0/go-auth0 v1.3.0/go.mod h1:gm0NUM340x77a9YVZB50HUrJJkSchD9DkiqqbAl+s34= github.com/aybabtme/iocontrol v0.0.0-20150809002002-ad15bcfc95a0 h1:0NmehRCgyk5rljDQLKUO+cRJCnduDyn11+zGZIc9Z48= github.com/aybabtme/iocontrol v0.0.0-20150809002002-ad15bcfc95a0/go.mod h1:6L7zgvqo0idzI7IO8de6ZC051AfXb5ipkIJ7bIA2tGA= github.com/aymanbagabas/go-osc52 v1.0.3 h1:DTwqENW7X9arYimJrPeGZcV0ln14sGMt3pHZspWD+Mg= From 205439459fbb500b6518083d5a2a9d181ca905a5 Mon Sep 17 00:00:00 2001 From: Michael Christenson II Date: Mon, 13 Nov 2023 12:10:00 -0500 Subject: [PATCH 2/4] dxcdt-615-goreleaser-upgrade (#909) * Fix: Remove or replace deprecations for GoReleaser config Remove deprecated replacements Replace deprecated brews tap Replace deprecated scoop entries Fix name_template to reflect exact current naming conventions * DXCDT-582: Convert audience into a drop down in interactive mode in test token cmd (#906) Convert audience into a drop down in interactive mode in test token cmd * Bump github.com/auth0/go-auth0 from 1.2.0 to 1.3.0 (#908) Bumps [github.com/auth0/go-auth0](https://github.com/auth0/go-auth0) from 1.2.0 to 1.3.0. - [Release notes](https://github.com/auth0/go-auth0/releases) - [Changelog](https://github.com/auth0/go-auth0/blob/main/CHANGELOG.md) - [Commits](https://github.com/auth0/go-auth0/compare/v1.2.0...v1.3.0) --- updated-dependencies: - dependency-name: github.com/auth0/go-auth0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --------- Signed-off-by: dependabot[bot] Co-authored-by: Sergiu Ghitea <28300158+sergiught@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .gitignore | 1 + .goreleaser.yml | 37 ++++++++++++++++--------------------- 2 files changed, 17 insertions(+), 21 deletions(-) diff --git a/.gitignore b/.gitignore index a1560ab06..2d6eec10e 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ /auth0 /test/integration/identifiers coverage* +/dist # Swap [._]*.s[a-v][a-z] diff --git a/.goreleaser.yml b/.goreleaser.yml index 2fdc5222f..e044543cc 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -18,12 +18,7 @@ builds: - -X 'github.com/auth0/auth0-cli/internal/buildinfo.BuildDate={{.Date}}' - -X 'github.com/auth0/auth0-cli/internal/instrumentation.SentryDSN={{.Env.SENTRY_DSN}}' archives: - - replacements: - darwin: Darwin - linux: Linux - windows: Windows - 386: i386 - amd64: x86_64 + - name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ if eq .Arch "arm64" }}arm64{{ else }}x86_64{{ end }}' files: - none* format_overrides: @@ -37,7 +32,7 @@ changelog: skip: true brews: - name: auth0 - tap: + repository: owner: auth0 name: homebrew-auth0-cli commit_author: @@ -54,17 +49,17 @@ brews: (fish_completion/"auth0.fish").write `#{bin}/auth0 completion fish` (zsh_completion/"_auth0").write `#{bin}/auth0 completion zsh` caveats: "Thanks for installing the Auth0 CLI" -scoop: - name: auth0 - bucket: - owner: auth0 - name: scoop-auth0-cli - commit_author: - name: auth0 - email: support@auth0.com - commit_msg_template: "Scoop manifest update for {{ .ProjectName }} version {{ .Tag }}" - homepage: https://auth0.github.io/auth0-cli - description: Build, manage and test your Auth0 integrations from the command line - license: MIT - skip_upload: auto - post_install: ["Write-Host 'Thanks for installing the Auth0 CLI'"] +scoops: + - name: auth0 + repository: + owner: auth0 + name: scoop-auth0-cli + commit_author: + name: auth0 + email: support@auth0.com + commit_msg_template: "Scoop manifest update for {{ .ProjectName }} version {{ .Tag }}" + homepage: https://auth0.github.io/auth0-cli + description: Build, manage and test your Auth0 integrations from the command line + license: MIT + skip_upload: auto + post_install: ["Write-Host 'Thanks for installing the Auth0 CLI'"] From 1da363159ffebcde4680b5fc9c4c54d19ad83c1b Mon Sep 17 00:00:00 2001 From: Sergiu Ghitea <28300158+sergiught@users.noreply.github.com> Date: Sat, 11 Nov 2023 09:05:49 +0100 Subject: [PATCH 3/4] DXCDT-582: Convert audience into a drop down in interactive mode in test token cmd (#906) Convert audience into a drop down in interactive mode in test token cmd Title Os for final release name fit --- .goreleaser.yml | 2 +- docs/auth0_test_login.md | 2 +- docs/auth0_test_token.md | 2 +- internal/cli/test.go | 78 ++++++++++++++++++++++++++++++++++++---- 4 files changed, 75 insertions(+), 9 deletions(-) diff --git a/.goreleaser.yml b/.goreleaser.yml index e044543cc..8b2e336e9 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -18,7 +18,7 @@ builds: - -X 'github.com/auth0/auth0-cli/internal/buildinfo.BuildDate={{.Date}}' - -X 'github.com/auth0/auth0-cli/internal/instrumentation.SentryDSN={{.Env.SENTRY_DSN}}' archives: - - name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ if eq .Arch "arm64" }}arm64{{ else }}x86_64{{ end }}' + - name_template: '{{ .ProjectName }}_{{ .Version }}_{{ title .Os }}_{{ if eq .Arch "arm64" }}arm64{{ else }}x86_64{{ end }}' files: - none* format_overrides: diff --git a/docs/auth0_test_login.md b/docs/auth0_test_login.md index 6dd41ee08..27a031a53 100644 --- a/docs/auth0_test_login.md +++ b/docs/auth0_test_login.md @@ -30,7 +30,7 @@ auth0 test login [flags] ## Flags ``` - -a, --audience string The unique identifier of the target API you want to access. + -a, --audience string The unique identifier of the target API you want to access. For Machine to Machine and Regular Web Applications, only the enabled APIs will be shown within the interactive prompt. -c, --connection-name string The connection name to test during login. -d, --domain string One of your custom domains. --force Skip confirmation. diff --git a/docs/auth0_test_token.md b/docs/auth0_test_token.md index 5ad8e2850..cdc62f310 100644 --- a/docs/auth0_test_token.md +++ b/docs/auth0_test_token.md @@ -27,7 +27,7 @@ auth0 test token [flags] ## Flags ``` - -a, --audience string The unique identifier of the target API you want to access. + -a, --audience string The unique identifier of the target API you want to access. For Machine to Machine and Regular Web Applications, only the enabled APIs will be shown within the interactive prompt. --force Skip confirmation. --json Output in json format. -s, --scopes strings The list of scopes you want to use. diff --git a/internal/cli/test.go b/internal/cli/test.go index e8f59f29f..b17f9d40a 100644 --- a/internal/cli/test.go +++ b/internal/cli/test.go @@ -36,7 +36,7 @@ var ( Name: "Audience", LongForm: "audience", ShortForm: "a", - Help: "The unique identifier of the target API you want to access.", + Help: "The unique identifier of the target API you want to access. For Machine to Machine and Regular Web Applications, only the enabled APIs will be shown within the interactive prompt.", } testAudienceRequired = Flag{ @@ -193,18 +193,20 @@ func testTokenCmd(cli *cli) *cobra.Command { return err } - if err := testAudience.Ask(cmd, &inputs.Audience, nil); err != nil { + if err := testAudienceRequired.Pick( + cmd, + &inputs.Audience, + cli.audiencePickerOptions(client), + ); err != nil { return err } - appType := client.GetAppType() - cli.renderer.Infof("Domain : " + ansi.Blue(cli.tenant)) cli.renderer.Infof("Client ID : " + ansi.Bold(client.GetClientID())) - cli.renderer.Infof("Type : " + display.ApplyColorToFriendlyAppType(display.FriendlyAppType(appType))) + cli.renderer.Infof("Type : " + display.ApplyColorToFriendlyAppType(display.FriendlyAppType(client.GetAppType()))) cli.renderer.Newline() - if appType == appTypeNonInteractive { + if client.GetAppType() == appTypeNonInteractive { tokenResponse, err := runClientCredentialsFlow(cmd.Context(), cli, client, inputs.Audience, cli.tenant) if err != nil { return fmt.Errorf( @@ -342,6 +344,70 @@ func (c *cli) appPickerWithCreateOption(ctx context.Context) (pickerOptions, err return enhancedOptions, nil } +func (c *cli) audiencePickerOptions(client *management.Client) func(ctx context.Context) (pickerOptions, error) { + return func(ctx context.Context) (pickerOptions, error) { + var opts pickerOptions + + switch client.GetAppType() { + case "regular_web", "non_interactive": + clientGrants, err := c.api.ClientGrant.List( + ctx, + management.PerPage(100), + management.Parameter("client_id", client.GetClientID()), + ) + if err != nil { + return nil, err + } + + if len(clientGrants.ClientGrants) == 0 { + return nil, fmt.Errorf( + "the %s application is not authorized to request access tokens for any APIs.\n\n"+ + "Run: 'auth0 apps open %s' to open the dashboard and authorize the application.", + ansi.Bold(client.GetName()), + client.GetClientID(), + ) + } + + for _, grant := range clientGrants.ClientGrants { + resourceServer, err := c.api.ResourceServer.Read(ctx, grant.GetAudience()) + if err != nil { + return nil, err + } + + label := fmt.Sprintf( + "%s %s", + resourceServer.GetName(), + ansi.Faint(fmt.Sprintf("(%s)", resourceServer.GetIdentifier())), + ) + + opts = append(opts, pickerOption{ + label: label, + value: resourceServer.GetIdentifier(), + }) + } + default: + resourceServerList, err := c.api.ResourceServer.List(ctx, management.PerPage(100)) + if err != nil { + return nil, err + } + + for _, resourceServer := range resourceServerList.ResourceServers { + label := fmt.Sprintf( + "%s %s", + resourceServer.GetName(), + ansi.Faint(fmt.Sprintf("(%s)", resourceServer.GetIdentifier())), + ) + opts = append(opts, pickerOption{ + label: label, + value: resourceServer.GetIdentifier(), + }) + } + } + + return opts, nil + } +} + func checkClientIsAuthorizedForAPI(ctx context.Context, cli *cli, client *management.Client, audience string) error { var list *management.ClientGrantList if err := ansi.Waiting(func() (err error) { From f338a40614d0615dbeec3675f4b1a0191b96169c Mon Sep 17 00:00:00 2001 From: Michael Christenson II Date: Tue, 21 Nov 2023 10:49:13 -0500 Subject: [PATCH 4/4] Pick logstream from list --- internal/cli/log_streams.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/cli/log_streams.go b/internal/cli/log_streams.go index ba13a007a..64d671016 100644 --- a/internal/cli/log_streams.go +++ b/internal/cli/log_streams.go @@ -104,7 +104,7 @@ func showLogStreamCmd(cli *cli) *cobra.Command { auth0 logs streams show --json`, RunE: func(cmd *cobra.Command, args []string) error { if len(args) == 0 { - err := logStreamID.Ask(cmd, &inputs.ID) + err := logStreamID.Pick(cmd, &inputs.ID, cli.allLogStreamsPickerOptions) if err != nil { return err }