Skip to content
This repository has been archived by the owner on Jan 15, 2019. It is now read-only.

Commit

Permalink
Fix disabled commands preventing read access to the Icinga Api
Browse files Browse the repository at this point in the history
fixes #4339
  • Loading branch information
Jannis Mosshammer authored and lazyfrosch committed Oct 2, 2013
1 parent 3943ea2 commit ab3e658
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
10 changes: 10 additions & 0 deletions app/modules/Api/actions/ApiCommandAction.class.php
Expand Up @@ -36,7 +36,17 @@ public function executeWrite(AgaviRequestDataHolder $rd) {
if (!$this->context->getUser()->isAuthenticated() || !$this->context->getUser()->hasCredential('icinga.user')) {
return array('Api', 'GenericError');
}
try {
if($this->context->getUser()->getNsmUser()->getTarget('IcingaCommandRo')) {
$errors = array('Commands are disabled for this user');
$this->getContainer()->setAttributeByRef('errors', $errors, 'org.icinga.api.auth');
$this->getContainer()->setAttribute('success', false, 'org.icinga.api.auth');
}
return array('Api', 'GenericError');

} catch (AppKitDoctrineException $e) {
// PASS
}
$command = $rd->getParameter("command");

$targets = json_decode($rd->getParameter("target"),true);
Expand Down
Expand Up @@ -63,13 +63,7 @@ public function onMatched(array &$parameters, AgaviExecutionContainer $container
}
}

try {
if($this->user->getNsmUser()->getTarget('IcingaCommandRo')) {
$errors[] = 'Commands are disabled for this user';
}
} catch (AppKitDoctrineException $e) {
// PASS
}


if ($this->checkAuthorisation() == false) {
$errors[] = self::INSUFFICIENT_MSG;
Expand Down

0 comments on commit ab3e658

Please sign in to comment.