From 76154c21d689ea29f83b1f4e656a052a4b356871 Mon Sep 17 00:00:00 2001 From: Airat Arifullin Date: Tue, 18 Jun 2024 14:33:45 +0300 Subject: [PATCH] [#1186] cli: Make owner field optional for bearer token Signed-off-by: Airat Arifullin --- cmd/frostfs-cli/modules/bearer/create.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/cmd/frostfs-cli/modules/bearer/create.go b/cmd/frostfs-cli/modules/bearer/create.go index d94b39207..a86506c37 100644 --- a/cmd/frostfs-cli/modules/bearer/create.go +++ b/cmd/frostfs-cli/modules/bearer/create.go @@ -67,7 +67,6 @@ func init() { _ = cobra.MarkFlagFilename(createCmd.Flags(), apeFlag) _ = cobra.MarkFlagRequired(createCmd.Flags(), commonflags.ExpireAt) - _ = cobra.MarkFlagRequired(createCmd.Flags(), ownerFlag) _ = cobra.MarkFlagRequired(createCmd.Flags(), outFlag) } @@ -108,16 +107,16 @@ func createToken(cmd *cobra.Command, _ []string) { fmt.Errorf("expiration epoch is less than not-valid-before epoch: %d < %d", exp, nvb)) } - ownerStr, _ := cmd.Flags().GetString(ownerFlag) - - var ownerID user.ID - commonCmd.ExitOnErr(cmd, "can't parse recipient: %w", ownerID.DecodeString(ownerStr)) - var b bearer.Token b.SetExp(exp) b.SetNbf(nvb) b.SetIat(iat) - b.ForUser(ownerID) + + if ownerStr, _ := cmd.Flags().GetString(ownerFlag); ownerStr != "" { + var ownerID user.ID + commonCmd.ExitOnErr(cmd, "can't parse recipient: %w", ownerID.DecodeString(ownerStr)) + b.ForUser(ownerID) + } impersonate, _ := cmd.Flags().GetBool(impersonateFlag) b.SetImpersonate(impersonate)