forked from TrueCloudLab/frostfs-node
[#1186] cli: Make owner field optional for bearer token
Signed-off-by: Airat Arifullin <a.arifullin@yadro.com>
This commit is contained in:
parent
40b68bcb6c
commit
11e880de7f
1 changed files with 6 additions and 7 deletions
|
@ -67,7 +67,6 @@ func init() {
|
||||||
_ = cobra.MarkFlagFilename(createCmd.Flags(), apeFlag)
|
_ = cobra.MarkFlagFilename(createCmd.Flags(), apeFlag)
|
||||||
|
|
||||||
_ = cobra.MarkFlagRequired(createCmd.Flags(), commonflags.ExpireAt)
|
_ = cobra.MarkFlagRequired(createCmd.Flags(), commonflags.ExpireAt)
|
||||||
_ = cobra.MarkFlagRequired(createCmd.Flags(), ownerFlag)
|
|
||||||
_ = cobra.MarkFlagRequired(createCmd.Flags(), outFlag)
|
_ = 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))
|
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
|
var b bearer.Token
|
||||||
b.SetExp(exp)
|
b.SetExp(exp)
|
||||||
b.SetNbf(nvb)
|
b.SetNbf(nvb)
|
||||||
b.SetIat(iat)
|
b.SetIat(iat)
|
||||||
|
|
||||||
|
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)
|
b.ForUser(ownerID)
|
||||||
|
}
|
||||||
|
|
||||||
impersonate, _ := cmd.Flags().GetBool(impersonateFlag)
|
impersonate, _ := cmd.Flags().GetBool(impersonateFlag)
|
||||||
b.SetImpersonate(impersonate)
|
b.SetImpersonate(impersonate)
|
||||||
|
|
Loading…
Reference in a new issue