fix: do not allow removal of inbuilt policies unless they are already persisted (#17264)

Dont allow removal of inbuilt policies such as `readwrite, readonly, writeonly and diagnostics`
This commit is contained in:
Shubhendu 2023-06-13 23:36:17 +05:30 committed by GitHub
parent 3d6b88a60e
commit 35d71682f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -532,6 +532,14 @@ func (sys *IAMSys) DeletePolicy(ctx context.Context, policyName string, notifyPe
return errServerNotInitialized
}
for _, v := range iampolicy.DefaultPolicies {
if v.Name == policyName {
if err := checkConfig(ctx, globalObjectAPI, getPolicyDocPath(policyName)); err != nil && err == errConfigNotFound {
return fmt.Errorf("inbuilt policy `%s` not allowed to be deleted", policyName)
}
}
}
err := sys.store.DeletePolicy(ctx, policyName)
if err != nil {
return err