Skip to content

Commit 28a7646

Browse files
authored
[envsec] Add show-tokens flag (#164)
## Summary TSIA ## How was it tested?
1 parent de89e93 commit 28a7646

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

envsec/internal/envcli/auth.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,12 @@ func refreshCmd() *cobra.Command {
9595
return cmd
9696
}
9797

98+
type whoAmICmdFlags struct {
99+
showTokens bool
100+
}
101+
98102
func whoAmICmd() *cobra.Command {
103+
flags := &whoAmICmdFlags{}
99104
cmd := &cobra.Command{
100105
Use: "whoami",
101106
Short: "Show the current user",
@@ -127,10 +132,24 @@ func whoAmICmd() *cobra.Command {
127132
fmt.Fprintf(cmd.OutOrStdout(), "Name: %s\n", idClaims.Name)
128133
}
129134

135+
if flags.showTokens {
136+
fmt.Fprintf(cmd.OutOrStdout(), "Access Token: %s\n", tok.AccessToken)
137+
fmt.Fprintf(cmd.OutOrStdout(), "ID Token: %s\n", tok.IDToken)
138+
fmt.Fprintf(cmd.OutOrStdout(), "Refresh Token: %s\n", tok.RefreshToken)
139+
140+
}
141+
130142
return nil
131143
},
132144
}
133145

146+
cmd.Flags().BoolVar(
147+
&flags.showTokens,
148+
"show-tokens",
149+
false,
150+
"Show the access, id, and refresh tokens",
151+
)
152+
134153
return cmd
135154
}
136155

0 commit comments

Comments
 (0)