From a687cbc27f11fee8e1964f2224da579dbbf8657b Mon Sep 17 00:00:00 2001 From: Anis Eleuch Date: Tue, 23 Apr 2024 18:02:47 +0100 Subject: [PATCH] svc: Return an error when the expiration, if defined, is in the past (#277) --- user-commands.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/user-commands.go b/user-commands.go index dd1e84da..62042aee 100644 --- a/user-commands.go +++ b/user-commands.go @@ -381,6 +381,9 @@ func (r *AddServiceAccountReq) Validate() error { if err != nil { return err } + if r.Expiration != nil && r.Expiration.Before(time.Now()) { + return errors.New("the expiration time should be in the future") + } return validateSADescription(r.Description) } @@ -488,6 +491,10 @@ func (u *UpdateServiceAccountReq) Validate() error { if err := validateSAName(u.NewName); err != nil { return err } + + if u.NewExpiration != nil && u.NewExpiration.Before(time.Now()) { + return errors.New("the expiration time should be in the future") + } return validateSADescription(u.NewDescription) }