Skip to content

Commit

Permalink
fix: truncate Expiration to second when Add ServiceAccount (minio#19674)
Browse files Browse the repository at this point in the history
Truncate Expiration at the second when Add ServiceAccount
  • Loading branch information
jiuker authored May 9, 2024
1 parent 2f7a10a commit 47a4ad3
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cmd/admin-handlers-users.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 47a4ad3

Please sign in to comment.