Skip to content

Commit

Permalink
Merge branch 'main' into feature/apis-list
Browse files Browse the repository at this point in the history
  • Loading branch information
Widcket authored Jan 25, 2021
2 parents d2dfe84 + 7fd930f commit e311593
Show file tree
Hide file tree
Showing 13 changed files with 289 additions and 11 deletions.
4 changes: 4 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module github.com/auth0/auth0-cli
go 1.14

require (
github.com/benbjohnson/clock v1.1.0 // indirect
github.com/briandowns/spinner v1.11.1
github.com/fatih/color v1.9.0 // indirect
github.com/logrusorgru/aurora v2.0.3+incompatible
Expand All @@ -18,3 +19,6 @@ require (
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
gopkg.in/yaml.v2 v2.2.8 // indirect
)

// replace gopkg.in/auth0.v5 => ../auth0
replace gopkg.in/auth0.v5 => github.com/go-auth0/auth0 v1.3.1-0.20210125191543-690e086040a7
10 changes: 7 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRF
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
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/benbjohnson/clock v1.0.3 h1:vkLuvpK4fmtSCuo60+yC63p7y0BmQ8gm5ZXGuBCJyXg=
github.com/benbjohnson/clock v1.0.3/go.mod h1:bGMdMPoPVvcYyt1gHDf4J2KE153Yf9BuiUKYMaxlTDM=
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
github.com/briandowns/spinner v1.11.1 h1:OixPqDEcX3juo5AjQZAnFPbeUA0jvkp2qzB5gOZJ/L0=
Expand All @@ -59,6 +60,7 @@ github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
github.com/cpuguy83/go-md2man/v2 v2.0.0 h1:EoUDS0afbrsXAZ9YQ9jdu/mZ2sXgT1/2yyNng4PGlyM=
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
Expand All @@ -76,6 +78,8 @@ github.com/fatih/color v1.9.0 h1:8xPHl4/q1VyqGIPif1F+1V3Y3lSmrq01EabUW3CoW5s=
github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/go-auth0/auth0 v1.3.1-0.20210125191543-690e086040a7 h1:6kaJtttAsJDTFy0RD2RVPw1DadgzDBiSbrsfTOSBjfI=
github.com/go-auth0/auth0 v1.3.1-0.20210125191543-690e086040a7/go.mod h1:pbIRmwBulkHNKKsUGGvhyIOI2itMhz2OfwtPaFXBSSQ=
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
Expand Down Expand Up @@ -192,7 +196,9 @@ github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7z
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
Expand Down Expand Up @@ -478,8 +484,6 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj
google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c=
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/auth0.v5 v5.8.0 h1:JWZV4CGRrWQeztZFuW1LWxgUqet6zLiZelGv470CxzU=
gopkg.in/auth0.v5 v5.8.0/go.mod h1:jVm6ZyPgF3Y1XpY4SPMPQM9NtRl8o3o/e2OuezsX97E=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
Expand Down
2 changes: 1 addition & 1 deletion internal/auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const (
deviceCodeEndpoint = "https://auth0.auth0.com/oauth/device/code"
oauthTokenEndpoint = "https://auth0.auth0.com/oauth/token"
// TODO(jfatta) extend the scope as we extend the CLI:
scope = "openid read:roles read:clients read:resource_servers read:logs read:rules"
scope = "openid blacklist:tokens create:actions create:actions create:client_grants create:client_keys create:clients create:connections create:custom_domains create:device_credentials create:email_provider create:email_templates create:guardian_enrollment_tickets create:hooks create:log_streams create:organization_connections create:organization_invitations create:organization_member_roles create:organization_members create:organizations create:passwords_checking_job create:resource_servers create:role_members create:roles create:rules create:shields create:signing_keys create:user_custom_blocks create:user_tickets create:users create:users_app_metadata delete:actions delete:actions delete:anomaly_blocks delete:branding delete:client_grants delete:client_keys delete:clients delete:connections delete:custom_domains delete:device_credentials delete:email_provider delete:grants delete:guardian_enrollments delete:hooks delete:log_streams delete:organization_connections delete:organization_invitations delete:organization_member_roles delete:organization_members delete:organizations delete:passwords_checking_job delete:resource_servers delete:role_members delete:roles delete:rules delete:rules_configs delete:shields delete:user_custom_blocks delete:users delete:users_app_metadata read:actions read:actions read:anomaly_blocks read:branding read:client_grants read:client_keys read:clients read:connections read:custom_domains read:device_credentials read:email_provider read:email_templates read:grants read:guardian_enrollments read:guardian_factors read:hooks read:limits read:log_streams read:logs read:logs_users read:mfa_policies read:organization_connections read:organization_invitations read:organization_member_roles read:organization_members read:organizations read:prompts read:resource_servers read:role_members read:roles read:rules read:rules_configs read:shields read:signing_keys read:stats read:tenant_settings read:triggers read:user_custom_blocks read:user_idp_tokens read:users read:users_app_metadata update:actions update:actions update:branding update:client_grants update:client_keys update:clients update:connections update:custom_domains update:device_credentials update:email_provider update:email_templates update:guardian_factors update:hooks update:limits update:log_streams update:mfa_policies update:organization_connections update:organizations update:prompts update:resource_servers update:roles update:rules update:rules_configs update:shields update:signing_keys update:tenant_settings update:triggers update:users update:users_app_metadata"
audiencePath = "/api/v2/"
)

Expand Down
40 changes: 40 additions & 0 deletions internal/cli/actions.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package cli

import (
"github.com/spf13/cobra"
)

func actionsCmd(cli *cli) *cobra.Command {
cmd := &cobra.Command{
Use: "actions",
Short: "manage resources for actions.",
}

cmd.SetUsageTemplate(resourceUsageTemplate())
cmd.AddCommand(listActionsCmd(cli))

return cmd
}

func listActionsCmd(cli *cli) *cobra.Command {
cmd := &cobra.Command{
Use: "list",
Short: "Lists your existing actions",
Long: `$ auth0 actions list
Lists your existing actions. To create one try:
$ auth0 actions create
`,
RunE: func(cmd *cobra.Command, args []string) error {
list, err := cli.api.Action.List()
if err != nil {
return err
}

cli.renderer.ActionList(list.Actions)
return nil
},
}

return cmd
}
1 change: 1 addition & 0 deletions internal/cli/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ func Execute() {
rootCmd.AddCommand(clientsCmd(cli))
rootCmd.AddCommand(apisCmd(cli))
rootCmd.AddCommand(logsCmd(cli))
rootCmd.AddCommand(actionsCmd(cli))
rootCmd.AddCommand(rulesCmd(cli))

// TODO(cyx): backport this later on using latest auth0/v5.
Expand Down
47 changes: 47 additions & 0 deletions internal/display/actions.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package display

import (
"strings"

"github.com/auth0/auth0-cli/internal/ansi"
"gopkg.in/auth0.v5"
"gopkg.in/auth0.v5/management"
)

type actionView struct {
ID string
Name string
CreatedAt string
Type string
}

func (v *actionView) AsTableHeader() []string {
return []string{"ID", "Name", "Type", "CreatedAt"}
}

func (v *actionView) AsTableRow() []string {
return []string{v.ID, v.Name, v.Type, v.CreatedAt}
}

func (r *Renderer) ActionList(actions []*management.Action) {
r.Heading(ansi.Bold(r.Tenant), "actions\n")

var res []View
for _, a := range actions {
var triggers = make([]string, 0, len(*a.SupportedTriggers))
for _, t := range *a.SupportedTriggers {
triggers = append(triggers, string(*t.ID))
}

res = append(res, &actionView{
ID: auth0.StringValue(a.ID),
Name: auth0.StringValue(a.Name),
CreatedAt: a.CreatedAt.String(),
Type: strings.Join(triggers, ", "),
// Runtime: auth0.StringValue(a.Runtime),
})

}

r.Results(res)
}
2 changes: 2 additions & 0 deletions vendor/gopkg.in/auth0.v5/go.mod

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

170 changes: 170 additions & 0 deletions vendor/gopkg.in/auth0.v5/management/actions.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions vendor/gopkg.in/auth0.v5/management/connection.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions vendor/gopkg.in/auth0.v5/management/management.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions vendor/gopkg.in/auth0.v5/management/user.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/gopkg.in/auth0.v5/meta.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit e311593

Please sign in to comment.