From e300b8fb3dce7022ab3085faa4cf0a5f2d78efc2 Mon Sep 17 00:00:00 2001 From: Lukas Hass Date: Sat, 28 Jan 2023 22:48:27 +0100 Subject: [PATCH] Allow setting access token scope by CLI --- cmd/admin.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/cmd/admin.go b/cmd/admin.go index a662011f9c079..8f8c68f9810c9 100644 --- a/cmd/admin.go +++ b/cmd/admin.go @@ -180,6 +180,11 @@ var ( Name: "raw", Usage: "Display only the token value", }, + cli.StringFlag{ + Name: "scopes", + Value: "", + Usage: "Comma separated list of scopes to apply to access token", + }, }, Action: runGenerateAccessToken, } @@ -698,9 +703,15 @@ func runGenerateAccessToken(c *cli.Context) error { return err } + accessTokenScope, err := auth_model.AccessTokenScope(c.String("scopes")).Normalize() + if err != nil { + return err + } + t := &auth_model.AccessToken{ - Name: c.String("token-name"), - UID: user.ID, + Name: c.String("token-name"), + UID: user.ID, + Scope: accessTokenScope, } if err := auth_model.NewAccessToken(t); err != nil {