From 9855a52787f58fce2aecd5c0537ca4aad25a4953 Mon Sep 17 00:00:00 2001 From: Cyril David Date: Fri, 5 Mar 2021 16:38:57 -0800 Subject: [PATCH 1/2] Update readme to demonstrate basic onboarding journey This onboarding journey is the initial set of steps to show what's possible with the CLI. We'll follow up with more docs later on, and potentially creating a separate docs site once the content gets too lengthy. --- README.md | 120 ++++++++++++++++++++++++++++++++++++++++++- internal/cli/cli.go | 3 +- internal/cli/logs.go | 4 +- 3 files changed, 121 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 201c8ee8a..09e1f87d6 100644 --- a/README.md +++ b/README.md @@ -22,11 +22,129 @@ Build, test, and manage your integration with **[Auth0](http://auth0.com/)** dir > see more completion options: `auth0 completion -h` +## Usage + +After installation, you should have the `auth0` command available: + +```bash +auth0 [command] + +# For any help, run --help after a specific command, e.g.: +auth0 [command] --help +``` + +### Onboarding Journey + +Following these instructions will give you a sense of what's possible with the +auth0 cli. To start, you will have to login: + +#### Login + +```bash +auth0 login +``` + +#### Creating your application + +If you haven't created an application yet, you may do so by running the +following command: + +```bash +auth0 apps create +``` + +A screen similar to the following will be presented after successful app creation: + +```bash +$ auth0 apps create + Name: my awesome app + Type: Regular Web Application + Description: dev tester +Creating application... done + +=== travel0 application created + + NAME my awesome app + TYPE regular web application + CLIENT ID vXAtoaFdhlmtWjpIrjb9AUnrGEAOH2MM + CLIENT SECRET QXV0aDAgaXMgaGlyaW5nISBhdXRoMC5jb20vY2FyZWVycyAK + + ▸ Quickstarts: https://auth0.com/docs/quickstart/webapp + ▸ Hint: You might wanna try `auth0 test login --client-id vXAtoaFdhlmtWjpIrjb9AUnrGEAOH2MM` +``` + +As you might observe, the next thing to do would likely be to try logging in +using the client ID. + +#### Testing the login flow + +Whether or not you've created the application using the CLI or the management +dashboard, you'll be able to test logging in using a specific application. + +If you have the client ID, you may specify it via the `--client-id` flag, +otherwise a prompt will be presented: + +``` +auth0 test login +``` + +#### Tailing your logs + +Once you have a few logins in place, you might wanna tail your logs. This is +done by running the following command: + +```bash +auth0 logs -f +``` + +After running that, one might see the following output: + +``` +Success Login 9 minutes ago Username-Password-Authentic... my awesome app +``` + +If there are errors encountered, such as the following example, you may run it +with the `--debug` flag as follows: + +```bash +auth0 logs -f --debug +``` + +The full raw data will be displayed below every error: + +``` +Failed Login hello 7 minutes ago N/A my awesome app + + id: "90020210306002808976000921438552554184272624146777636962" + logid: "90020210306002808976000921438552554184272624146777636962" + date: 2021-03-06T00:28:04.91Z + type: f + clientid: vXAtoaFdhlmtWjpIrjb9AUnrGEAOH2MM + clientname: my awesome app + ip: 1.2.3.4 + description: hello + locationinfo: {} + details: + body: + action: default + password: '*****' + state: QXV0aDAgaXMgaGlyaW5nISBhdXRoMC5jb20vY2FyZWVycyAK + username: j.doe@gmail.com + connection: Username-Password-Authentication + error: + message: hello + oauthError: access_denied + type: oauth-authorization + qs: {} + session_id: QXV0aDAgaXMgaGlyaW5nISBhdXRoMC5jb20vY2FyZWVycyAK + userid: auth0|QXV0aDAgaXMgaGlyaW5nISBhdXRoMC5jb20vY2FyZWVycyAK +``` + ## Contributing Please check the [contributing guidelines](CONTRIBUTING.md). -## Author +## Author [Auth0](https://auth0.com) diff --git a/internal/cli/cli.go b/internal/cli/cli.go index d61805d7c..af9149112 100644 --- a/internal/cli/cli.go +++ b/internal/cli/cli.go @@ -134,7 +134,6 @@ func (c *cli) setup(ctx context.Context) error { if t.AccessToken != "" { m, err := management.New(t.Domain, management.WithStaticToken(t.AccessToken), - management.WithDebug(c.debug), management.WithUserAgent(userAgent)) if err != nil { return err @@ -311,7 +310,7 @@ func shouldPromptWhenFlagless(cmd *cobra.Command, flag string) bool { isSet := false cmd.LocalFlags().VisitAll(func(f *pflag.Flag) { - if (f.Changed) { + if f.Changed { isSet = true } }) diff --git a/internal/cli/logs.go b/internal/cli/logs.go index b938e671e..6e005433e 100644 --- a/internal/cli/logs.go +++ b/internal/cli/logs.go @@ -32,7 +32,6 @@ func logsCmd(cli *cli) *cobra.Command { Num int Follow bool NoColor bool - Silent bool } cmd := &cobra.Command{ @@ -102,7 +101,7 @@ Show the tenant logs. cli.api.ActionExecution, time.Second, ) - cli.renderer.LogList(list, logsCh, actionExecutionAPI, flags.NoColor, flags.Silent) + cli.renderer.LogList(list, logsCh, actionExecutionAPI, flags.NoColor, cli.debug == false) return nil }, } @@ -110,7 +109,6 @@ Show the tenant logs. cmd.Flags().IntVarP(&flags.Num, "num-entries", "n", 100, "the number of log entries to print") cmd.Flags().BoolVarP(&flags.Follow, "follow", "f", false, "Specify if the logs should be streamed") cmd.Flags().BoolVar(&flags.NoColor, "no-color", false, "turn off colored print") - cmd.Flags().BoolVarP(&flags.Silent, "silent", "s", false, "do not display extended raw data") return cmd } From e2b9c56fe21f0f7a02f48d0b939c173edcfcc5da Mon Sep 17 00:00:00 2001 From: Cyril David Date: Fri, 5 Mar 2021 17:13:28 -0800 Subject: [PATCH 2/2] Lint --- internal/cli/logs.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/cli/logs.go b/internal/cli/logs.go index 6e005433e..4e97f71fd 100644 --- a/internal/cli/logs.go +++ b/internal/cli/logs.go @@ -101,7 +101,7 @@ Show the tenant logs. cli.api.ActionExecution, time.Second, ) - cli.renderer.LogList(list, logsCh, actionExecutionAPI, flags.NoColor, cli.debug == false) + cli.renderer.LogList(list, logsCh, actionExecutionAPI, flags.NoColor, !cli.debug) return nil }, }