From 57b7089fad8dbf965eb19c57b21d320983ac47fe Mon Sep 17 00:00:00 2001 From: Patrick Carey Date: Tue, 26 Jan 2021 20:53:56 +0000 Subject: [PATCH] fix: remove --reveal flag from try-login, always show tokens (#46) --- internal/cli/try_login.go | 4 +--- internal/display/try_login.go | 17 +---------------- 2 files changed, 2 insertions(+), 19 deletions(-) diff --git a/internal/cli/try_login.go b/internal/cli/try_login.go index ca1d5b852..350ac8271 100644 --- a/internal/cli/try_login.go +++ b/internal/cli/try_login.go @@ -28,7 +28,6 @@ const ( func tryLoginCmd(cli *cli) *cobra.Command { var clientID string var connectionName string - var reveal bool cmd := &cobra.Command{ Use: "try-login", @@ -141,7 +140,7 @@ Launch a browser to try out your universal login box for the given client. } fmt.Fprint(cli.renderer.MessageWriter, "\n") - cli.renderer.TryLogin(userInfo, tokenResponse, reveal) + cli.renderer.TryLogin(userInfo, tokenResponse) return nil }, } @@ -149,7 +148,6 @@ Launch a browser to try out your universal login box for the given client. cmd.SetUsageTemplate(resourceUsageTemplate()) cmd.Flags().StringVarP(&clientID, "client-id", "c", "", "Client ID for which to test login.") cmd.Flags().StringVarP(&connectionName, "connection", "", "", "Connection to test during login.") - cmd.Flags().BoolVarP(&reveal, "reveal", "r", false, "⚠️ Reveal tokens after successful login.") return cmd } diff --git a/internal/display/try_login.go b/internal/display/try_login.go index 8b83745e6..4f2f90125 100644 --- a/internal/display/try_login.go +++ b/internal/display/try_login.go @@ -26,15 +26,9 @@ func isNotZero(v interface{}) bool { return v != reflect.Zero(t).Interface() } -func (r *Renderer) TryLogin(u *auth.UserInfo, t *auth.TokenResponse, reveal bool) { +func (r *Renderer) TryLogin(u *auth.UserInfo, t *auth.TokenResponse) { r.Heading(ansi.Bold(auth0.StringValue(u.Sub)), "/userinfo\n") - if !reveal { - t.AccessToken = "[REDACTED]" - t.RefreshToken = "[REDACTED]" - t.IDToken = "[REDACTED]" - } - switch r.Format { case OutputFormatJSON: out := &userInfoAndTokens{UserInfo: u, Tokens: t} @@ -103,23 +97,14 @@ func (r *Renderer) TryLogin(u *auth.UserInfo, t *auth.TokenResponse, reveal bool rows = append(rows, []string{ansi.Faint("UpdatedAt"), auth0.TimeValue(u.UpdatedAt).Format(time.RFC3339)}) } if isNotZero(t.AccessToken) { - if !reveal { - t.AccessToken = ansi.Faint(t.AccessToken) - } rows = append(rows, []string{ansi.Faint("AccessToken"), t.AccessToken}) } if isNotZero(t.RefreshToken) { - if !reveal { - t.RefreshToken = ansi.Faint(t.RefreshToken) - } rows = append(rows, []string{ansi.Faint("RefreshToken"), t.RefreshToken}) } // TODO: This is a long string and it messes up formatting when printed // to the table, so need to come back to this one and fix it later. // if isNotZero(t.IDToken) { - // if !reveal { - // t.IDToken = ansi.Faint(t.IDToken) - // } // rows = append(rows, []string{ansi.Faint("IDToken"), t.IDToken}) // } if isNotZero(t.TokenType) {