mirror of https://github.com/Icinga/icinga2.git
Don't allow users to delete objects that weren't created using the API
refs #9082
This commit is contained in:
parent
d118b71a2a
commit
60a30d50f6
|
@ -61,6 +61,7 @@ bool CreateObjectHandler::HandleRequest(const ApiUser::Ptr& user, HttpRequest& r
|
|||
builder->SetType(type->GetName());
|
||||
builder->SetName(name);
|
||||
builder->SetScope(ScriptGlobal::GetGlobals());
|
||||
builder->SetModule("_api");
|
||||
|
||||
Array::Ptr templates = params->Get("templates");
|
||||
|
||||
|
|
|
@ -65,6 +65,13 @@ bool DeleteObjectHandler::HandleRequest(const ApiUser::Ptr& user, HttpRequest& r
|
|||
Dictionary::Ptr result1 = new Dictionary();
|
||||
result1->Set("type", type->GetName());
|
||||
result1->Set("name", obj->GetName());
|
||||
results->Add(result1);
|
||||
|
||||
if (obj->GetModule() != "_api") {
|
||||
result1->Set("code", 500);
|
||||
result1->Set("status", "Object cannot be deleted because it was not created using the API.");
|
||||
continue;
|
||||
}
|
||||
|
||||
ConfigItem::Ptr item = ConfigItem::GetObject(type->GetName(), obj->GetName());
|
||||
|
||||
|
@ -82,8 +89,6 @@ bool DeleteObjectHandler::HandleRequest(const ApiUser::Ptr& user, HttpRequest& r
|
|||
result1->Set("code", 500);
|
||||
result1->Set("status", "Object could not be deleted: " + DiagnosticInformation(ex));
|
||||
}
|
||||
|
||||
results->Add(result1);
|
||||
}
|
||||
|
||||
Dictionary::Ptr result = new Dictionary();
|
||||
|
|
Loading…
Reference in New Issue