-
Notifications
You must be signed in to change notification settings - Fork 0
/
revoke.go
60 lines (48 loc) · 1.01 KB
/
revoke.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package refresh
import (
"context"
"errors"
"fmt"
"github.com/dexidp/dex/api/v2"
"github.com/twoojoo/dexctl/setup"
"github.com/twoojoo/dexctl/utils"
"github.com/urfave/cli"
)
var RevokeRefreshFlags []cli.Flag = []cli.Flag{
cli.StringFlag{
Name: "grpc-url, g",
Value: "127.0.0.1:5557",
Usage: "gRPC host and port",
},
}
func RevokeRefresh(c *cli.Context) error {
ctx := context.Background()
grpc, err := setup.SetupGrpcClient(ctx, c)
if err != nil {
return err
}
clientID := c.Args().Get(0)
if clientID == "" {
return errors.New("client id must be provided as first argument")
}
userID := c.Args().Get(1)
if userID == "" {
return errors.New("user id must be provided as first argument")
}
resp, err := grpc.RevokeRefresh(ctx, &api.RevokeRefreshReq{
UserId: userID,
ClientId: clientID,
})
if err != nil {
return err
}
if resp.NotFound {
return errors.New("client/user not found")
}
p, err := utils.PrettifyJSON(resp)
if err != nil {
return err
}
fmt.Println(p)
return nil
}