Skip to content

Commit

Permalink
Merge branch 'v1' into DXCDT-267-more-reliable-access-token-regen
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiught authored Dec 9, 2022
2 parents 2bcd603 + 64f9db8 commit 09b9e5a
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 74 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ name: Go

on: [push, pull_request]

env:
GO_VERSION: 1.19.4

concurrency:
group: one-at-time
cancel-in-progress: false
Expand All @@ -18,7 +21,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19.3
go-version: ${{env.GO_VERSION}}

- name: Check out the code
uses: actions/checkout@v3
Expand All @@ -45,7 +48,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19.3
go-version: ${{env.GO_VERSION}}

- name: Check out the code
uses: actions/checkout@v3
Expand All @@ -58,8 +61,6 @@ jobs:
AUTH0_CLI_CLIENT_DOMAIN: ${{ secrets.AUTH0_CLI_CLIENT_DOMAIN }}
AUTH0_CLI_CLIENT_ID: ${{ secrets.AUTH0_CLI_CLIENT_ID }}
AUTH0_CLI_CLIENT_SECRET: ${{ secrets.AUTH0_CLI_CLIENT_SECRET }}
AUTH0_CLI_REUSE_CONFIG: ${{ secrets.AUTH0_CLI_REUSE_CONFIG }}
AUTH0_CLI_OVERWRITE: ${{ secrets.AUTH0_CLI_OVERWRITE }}

build:
name: Build
Expand All @@ -72,7 +73,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19.3
go-version: ${{env.GO_VERSION}}

- name: Check out the code
uses: actions/checkout@v3
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ on:
pull_request:
push:

env:
GO_VERSION: 1.19.4

jobs:
goreleaser:
runs-on: ubuntu-latest
Expand All @@ -20,7 +23,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19.3
go-version: ${{env.GO_VERSION}}

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v3
Expand Down
11 changes: 1 addition & 10 deletions cmd/build_doc/main.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
package main

import (
"github.com/joeshaw/envdecode"

"github.com/auth0/auth0-cli/internal/cli"
)

func main() {
var cfg struct {
Path string `env:"AUTH0_CLI_DOCS_PATH,default=./docs/"`
}
if err := envdecode.StrictDecode(&cfg); err != nil {
panic(err)
}

err := cli.BuildDoc(cfg.Path)
err := cli.BuildDoc()
if err != nil {
panic(err)
}
Expand Down
8 changes: 4 additions & 4 deletions docs/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -212,20 +212,20 @@ GEM
jekyll-feed (~> 0.9)
jekyll-seo-tag (~> 2.1)
minitest (5.16.3)
nokogiri (1.13.9)
nokogiri (1.13.10)
mini_portile2 (~> 2.8.0)
racc (~> 1.4)
nokogiri (1.13.9-x86_64-darwin)
nokogiri (1.13.10-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.13.9-x86_64-linux)
nokogiri (1.13.10-x86_64-linux)
racc (~> 1.4)
octokit (4.25.1)
faraday (>= 1, < 3)
sawyer (~> 0.9)
pathutil (0.16.2)
forwardable-extended (~> 2.6)
public_suffix (4.0.7)
racc (1.6.0)
racc (1.6.1)
rb-fsevent (0.11.2)
rb-inotify (0.10.1)
ffi (~> 1.0)
Expand Down
14 changes: 6 additions & 8 deletions docs/auth0_login.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ layout: default
Authenticate the Auth0 CLI

### Synopsis
Authenticates the Auth0 CLI either as a user using personal credentials or as a machine using client credentials.

Authenticates the Auth0 CLI either as a user using personal credentials or as a machine using client credentials (client ID/secret).

```
auth0 login [flags]
Expand All @@ -16,18 +16,16 @@ auth0 login [flags]
### Examples

```
auth0 login
auth0 login --domain <tenant-domain> --client-id <client-id> --client-secret <client-secret>
auth0 login
auth0 login --domain <tenant-domain> --client-id <client-id> --client-secret <client-secret>
```

### Options

```
-i, --client-id string Client ID of the application.
-s, --client-secret string Client Secret of the application.
--domain string Specifies tenant domain when authenticating via client credentials (client ID, client secret)
--client-id string Client ID of the application when authenticating via client credentials.
--client-secret string Client secret of the application when authenticating via client credentials.
--domain string Tenant domain of the application when authenticating via client credentials.
-h, --help help for login
```

Expand Down
25 changes: 0 additions & 25 deletions docs/ci.md

This file was deleted.

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/briandowns/spinner v1.19.0
github.com/charmbracelet/glamour v0.6.0
github.com/fsnotify/fsnotify v1.6.0
github.com/getsentry/sentry-go v0.15.0
github.com/getsentry/sentry-go v0.16.0
github.com/golang/mock v1.6.0
github.com/google/go-cmp v0.5.9
github.com/google/uuid v1.3.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYF
github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE=
github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY=
github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw=
github.com/getsentry/sentry-go v0.15.0 h1:CP9bmA7pralrVUedYZsmIHWpq/pBtXTSew7xvVpfLaA=
github.com/getsentry/sentry-go v0.15.0/go.mod h1:RZPJKSw+adu8PBNygiri/A98FqVr2HtRckJk9XVxJ9I=
github.com/getsentry/sentry-go v0.16.0 h1:owk+S+5XcgJLlGR/3+3s6N4d+uKwqYvh/eS0AIMjPWo=
github.com/getsentry/sentry-go v0.16.0/go.mod h1:ZXCloQLj0pG7mja5NK6NPf2V4A88YJ4pNlc2mOHwh6Y=
github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA=
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=
Expand Down
6 changes: 4 additions & 2 deletions internal/cli/build_doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/spf13/cobra/doc"
)

func BuildDoc(path string) error {
func BuildDoc() error {
cli := &cli{}

rootCmd := &cobra.Command{
Expand All @@ -20,8 +20,10 @@ func BuildDoc(path string) error {
addPersistentFlags(rootCmd, cli)
addSubcommands(rootCmd, cli)

docsPath := "./docs/"

err := doc.GenMarkdownTreeCustom(rootCmd,
path,
docsPath,
func(fileName string) string {
// prepend to the generated markdown
if strings.HasSuffix(fileName, "auth0.md") {
Expand Down
40 changes: 24 additions & 16 deletions internal/cli/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,25 @@ var (
loginTenantDomain = Flag{
Name: "Tenant Domain",
LongForm: "domain",
Help: "Specifies tenant domain when authenticating via client credentials (client ID, client secret)",
Help: "Tenant domain of the application when authenticating via client credentials.",
IsRequired: false,
AlwaysPrompt: true,
AlwaysPrompt: false,
}

loginClientID = Flag{
Name: "Client ID",
LongForm: "client-id",
Help: "Client ID of the application.",
IsRequired: true,
AlwaysPrompt: true,
Help: "Client ID of the application when authenticating via client credentials.",
IsRequired: false,
AlwaysPrompt: false,
}

loginClientSecret = Flag{
Name: "Client Secret",
LongForm: "client-secret",
Help: "Client Secret of the application.",
IsRequired: true,
AlwaysPrompt: true,
Help: "Client secret of the application when authenticating via client credentials.",
IsRequired: false,
AlwaysPrompt: false,
}
)

Expand All @@ -44,24 +44,24 @@ type LoginInputs struct {
ClientSecret string
}

func (i *LoginInputs) shouldLoginAsMachine() bool {
return i.ClientID != "" || i.ClientSecret != "" || i.Domain != ""
}

func loginCmd(cli *cli) *cobra.Command {
var inputs LoginInputs

cmd := &cobra.Command{
Use: "login",
Args: cobra.NoArgs,
Short: "Authenticate the Auth0 CLI",
Long: "Authenticates the Auth0 CLI either as a user using personal credentials or as a machine using client credentials (client ID/secret).",
Example: `
auth0 login
auth0 login --domain <tenant-domain> --client-id <client-id> --client-secret <client-secret>
`,
Long: "Authenticates the Auth0 CLI either as a user using personal credentials or as a machine using client credentials.",
Example: `auth0 login
auth0 login --domain <tenant-domain> --client-id <client-id> --client-secret <client-secret>`,
RunE: func(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()

shouldLoginAsMachine := inputs.ClientID != "" || inputs.ClientSecret != "" || inputs.Domain != ""

if shouldLoginAsMachine {
if inputs.shouldLoginAsMachine() {
if err := RunLoginAsMachine(ctx, inputs, cli, cmd); err != nil {
return err
}
Expand Down Expand Up @@ -222,5 +222,13 @@ func RunLoginAsMachine(ctx context.Context, inputs LoginInputs, cli *cli, cmd *c
return fmt.Errorf("unexpected error when attempting to save tenant data: %w", err)
}

cli.renderer.Newline()
cli.renderer.Infof("Successfully logged in.")
cli.renderer.Infof("Tenant: %s", inputs.Domain)

if err := checkInstallID(cli); err != nil {
return fmt.Errorf("failed to update the config: %w", err)
}

return nil
}

0 comments on commit 09b9e5a

Please sign in to comment.