Skip to content

Commit 3f2e721

Browse files
lukashasslunnyjolheiser
authored
Allow setting access token scope by CLI (#22648)
Followup for #20908 to allow setting the scopes when creating new access token via CLI. Co-authored-by: Lunny Xiao <[email protected]> Co-authored-by: John Olheiser <[email protected]>
1 parent 15c0357 commit 3f2e721

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

cmd/admin.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,11 @@ var (
180180
Name: "raw",
181181
Usage: "Display only the token value",
182182
},
183+
cli.StringFlag{
184+
Name: "scopes",
185+
Value: "",
186+
Usage: "Comma separated list of scopes to apply to access token",
187+
},
183188
},
184189
Action: runGenerateAccessToken,
185190
}
@@ -698,9 +703,15 @@ func runGenerateAccessToken(c *cli.Context) error {
698703
return err
699704
}
700705

706+
accessTokenScope, err := auth_model.AccessTokenScope(c.String("scopes")).Normalize()
707+
if err != nil {
708+
return err
709+
}
710+
701711
t := &auth_model.AccessToken{
702-
Name: c.String("token-name"),
703-
UID: user.ID,
712+
Name: c.String("token-name"),
713+
UID: user.ID,
714+
Scope: accessTokenScope,
704715
}
705716

706717
if err := auth_model.NewAccessToken(t); err != nil {

0 commit comments

Comments
 (0)