MCPcopy Create free account
hub / github.com/GetStream/stream-cli / revokeAllTokensCmd

Function revokeAllTokensCmd

pkg/cmd/chat/app/app.go:112–154  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

110}
111
112func revokeAllTokensCmd() *cobra.Command {
113 cmd := &cobra.Command{
114 Use: "revoke-all-tokens --before [epoch]",
115 Short: "Revoke all tokens",
116 Long: heredoc.Doc(`
117 This command revokes ALL tokens for all users of an application.
118 This should be used with caution as it will expire every user’s token,
119 regardless of whether the token has an iat claim.
120 `),
121 Example: heredoc.Doc(`
122 # Revoke all tokens for the default app, from now
123 $ stream-cli chat revoke-all-tokens
124
125 # Revoke all tokens for the test app, before 2019-01-01
126 $ stream-cli chat revoke-all-tokens --before 1546300800 --app test
127 `),
128 RunE: func(cmd *cobra.Command, args []string) error {
129 c, err := config.GetConfig(cmd).GetClient(cmd)
130 if err != nil {
131 return err
132 }
133
134 before, _ := cmd.Flags().GetInt64("before")
135 if before == 0 {
136 before = time.Now().Unix()
137 }
138 beforeDate := time.Unix(before, 0)
139
140 _, err = c.RevokeTokens(cmd.Context(), &beforeDate)
141 if err != nil {
142 return err
143 }
144
145 cmd.Println("Successfully revoked all tokens.")
146 return nil
147 },
148 }
149
150 fl := cmd.Flags()
151 fl.Int64P("before", "b", 0, "[optional] The epoch timestamp before which tokens should be revoked. Defaults to now.")
152
153 return cmd
154}

Callers 1

NewCmdsFunction · 0.85

Calls 2

GetConfigFunction · 0.92
GetClientMethod · 0.80

Tested by

no test coverage detected