fix: do not return an error on expired credentials (#12057)

policy might have an associated mapping with an expired
user key, do not return an error during DeletePolicy
for such situations - proceed normally as its an
expected situation.
This commit is contained in:
Harshavardhana 2021-04-15 08:51:01 -07:00 committed by GitHub
parent 885c170a64
commit 39dd9b6483
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 2 deletions

View File

@ -672,8 +672,10 @@ func (sys *IAMSys) DeletePolicy(policyName string) error {
if pset.Contains(policyName) {
cr, ok := sys.iamUsersMap[u]
if !ok {
// This case cannot happen
return errNoSuchUser
// This case can happen when an temporary account
// is deleted or expired, removed it from userPolicyMap.
delete(sys.iamUserPolicyMap, u)
continue
}
pset.Remove(policyName)
// User is from STS if the cred are temporary