cli: Make owner field optional for bearer token #1186
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)
|
||||||
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)
|
impersonate, _ := cmd.Flags().GetBool(impersonateFlag)
|
||||||
b.SetImpersonate(impersonate)
|
b.SetImpersonate(impersonate)
|
||||||
|
|
Loading…
Reference in a new issue