From 47a4ad3cd7ebe8d945c142a898b233c4a7969ae9 Mon Sep 17 00:00:00 2001 From: jiuker <2818723467@qq.com> Date: Fri, 10 May 2024 02:08:04 +0800 Subject: [PATCH] fix: truncate Expiration to second when Add ServiceAccount (#19674) Truncate Expiration at the second when Add ServiceAccount --- cmd/admin-handlers-users.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cmd/admin-handlers-users.go b/cmd/admin-handlers-users.go index b7b76e0c2..b37931400 100644 --- a/cmd/admin-handlers-users.go +++ b/cmd/admin-handlers-users.go @@ -2476,6 +2476,12 @@ func commonAddServiceAccount(r *http.Request) (context.Context, auth.Credentials return ctx, auth.Credentials{}, newServiceAccountOpts{}, madmin.AddServiceAccountReq{}, "", errorCodes.ToAPIErrWithErr(ErrAdminConfigBadJSON, err) } + if createReq.Expiration != nil && !createReq.Expiration.IsZero() { + // truncate expiration at the second. + truncateTime := createReq.Expiration.Truncate(time.Second) + createReq.Expiration = &truncateTime + } + // service account access key cannot have space characters beginning and end of the string. if hasSpaceBE(createReq.AccessKey) { return ctx, auth.Credentials{}, newServiceAccountOpts{}, madmin.AddServiceAccountReq{}, "", errorCodes.ToAPIErr(ErrAdminResourceInvalidArgument)