fix: truncate Expiration to second when Add ServiceAccount (#19674)

Truncate Expiration at the second when Add ServiceAccount
This commit is contained in:
jiuker 2024-05-10 02:08:04 +08:00 committed by GitHub
parent 2f7a10ab31
commit 47a4ad3cd7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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)