From 8d573e190dac0fbdb955d0b7ca277749f80bb5db Mon Sep 17 00:00:00 2001 From: Mike Landau Date: Thu, 28 Sep 2023 13:48:58 -0700 Subject: [PATCH] [envsec] Add show-tokens flag --- envsec/internal/envcli/auth.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/envsec/internal/envcli/auth.go b/envsec/internal/envcli/auth.go index 9144d907..88ff368e 100644 --- a/envsec/internal/envcli/auth.go +++ b/envsec/internal/envcli/auth.go @@ -91,7 +91,12 @@ func refreshCmd() *cobra.Command { return cmd } +type whoAmICmdFlags struct { + showTokens bool +} + func whoAmICmd() *cobra.Command { + flags := &whoAmICmdFlags{} cmd := &cobra.Command{ Use: "whoami", Short: "Show the current user", @@ -123,10 +128,24 @@ func whoAmICmd() *cobra.Command { fmt.Fprintf(cmd.OutOrStdout(), "Name: %s\n", idClaims.Name) } + if flags.showTokens { + fmt.Fprintf(cmd.OutOrStdout(), "Access Token: %s\n", tok.AccessToken) + fmt.Fprintf(cmd.OutOrStdout(), "ID Token: %s\n", tok.IDToken) + fmt.Fprintf(cmd.OutOrStdout(), "Refresh Token: %s\n", tok.RefreshToken) + + } + return nil }, } + cmd.Flags().BoolVar( + &flags.showTokens, + "show-tokens", + false, + "Show the access, id, and refresh tokens", + ) + return cmd }