From d8e28830cf0f30bd9a0e70f4cf5fa655eba5853a Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Sat, 19 Dec 2020 13:24:21 -0800 Subject: [PATCH] fix: allow STS creds for admin accounts to add users (#11138) Allow rotating creds with privileges to add users fixes https://github.com/minio/console/issues/529 --- cmd/admin-handlers-users.go | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/cmd/admin-handlers-users.go b/cmd/admin-handlers-users.go index 89e9a2d6f..c6c6f4b94 100644 --- a/cmd/admin-handlers-users.go +++ b/cmd/admin-handlers-users.go @@ -373,23 +373,29 @@ func (a adminAPIHandlers) AddUser(w http.ResponseWriter, r *http.Request) { return } - if cred.IsTemp() || cred.IsServiceAccount() { - writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(ErrAccountNotEligible), r.URL) - return - } - // Not allowed to add a user with same access key as root credential if owner && accessKey == cred.AccessKey { writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(ErrAddUserInvalidArgument), r.URL) return } + if (cred.IsTemp() || cred.IsServiceAccount()) && cred.ParentUser == accessKey { + // Incoming access key matches parent user then we should + // reject password change requests. + writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(ErrAddUserInvalidArgument), r.URL) + return + } + implicitPerm := accessKey == cred.AccessKey if !implicitPerm { + parentUser := cred.ParentUser + if parentUser == "" { + parentUser = cred.AccessKey + } if !globalIAMSys.IsAllowed(iampolicy.Args{ - AccountName: cred.AccessKey, + AccountName: parentUser, Action: iampolicy.CreateUserAdminAction, - ConditionValues: getConditionValues(r, "", cred.AccessKey, claims), + ConditionValues: getConditionValues(r, "", parentUser, claims), IsOwner: owner, Claims: claims, }) {