Skip to content

Commit

Permalink
fix: remove --reveal flag from try-login, always show tokens (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Carey authored Jan 26, 2021
1 parent df22431 commit 57b7089
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 19 deletions.
4 changes: 1 addition & 3 deletions internal/cli/try_login.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -141,15 +140,14 @@ 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
},
}

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
}

Expand Down
17 changes: 1 addition & 16 deletions internal/display/try_login.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 57b7089

Please sign in to comment.