Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

fix(CLAPI): check for "Reach API *" fields in user instead of "Reach … #7117

Merged
merged 4 commits into from
Jan 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 28 additions & 28 deletions www/class/centreon-clapi/centreonAPI.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -517,41 +517,41 @@ public function checkUser($useSha1 = false, $isWorker = false)
$DBRESULT = $this->DB->query("SELECT *
FROM contact
WHERE contact_alias = '" . $this->login . "'
AND contact_activate = '1'
AND contact_oreon = '1'");
AND contact_activate = '1'");

if ($DBRESULT->rowCount()) {
$row = $DBRESULT->fetchRow();

if ($row['contact_admin'] == 1) {
$algo = $this->dependencyInjector['utils']->detectPassPattern($row['contact_passwd']);
if (!$algo) {
if ($useSha1) {
$row['contact_passwd'] = 'sha1__' . $row['contact_passwd'];
} else {
$row['contact_passwd'] = 'md5__' . $row['contact_passwd'];
}
if ($row['contact_admin'] == 0) {
print "You don't have permissions for CLAPI.\n";
exit(1);
}

$algo = $this->dependencyInjector['utils']->detectPassPattern($row['contact_passwd']);
if (!$algo) {
if ($useSha1) {
$row['contact_passwd'] = 'sha1__' . $row['contact_passwd'];
} else {
$row['contact_passwd'] = 'md5__' . $row['contact_passwd'];
}
if ($row['contact_passwd'] == $pass) {
}
if ($row['contact_passwd'] == $pass) {
\CentreonClapi\CentreonUtils::setUserId($row['contact_id']);
return 1;
} elseif ($row['contact_auth_type'] == 'ldap') {
$CentreonLog = new \CentreonUserLog(-1, $this->DB);
$centreonAuth = new \CentreonAuthLDAP(
$this->DB,
$CentreonLog,
$this->login,
$this->password,
$row,
$row['ar_id']
);
if ($centreonAuth->checkPassword() == 1) {
\CentreonClapi\CentreonUtils::setUserId($row['contact_id']);
return 1;
} elseif ($row['contact_auth_type'] == 'ldap') {
$CentreonLog = new \CentreonUserLog(-1, $this->DB);
$centreonAuth = new \CentreonAuthLDAP(
$this->DB,
$CentreonLog,
$this->login,
$this->password,
$row,
$row['ar_id']
);
if ($centreonAuth->checkPassword() == 1) {
\CentreonClapi\CentreonUtils::setUserId($row['contact_id']);
return 1;
}
}
} else {
print "Centreon CLAPI is for admin users only.\n";
exit(1);
}
}
print "Invalid credentials.\n";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,14 @@
* Check if this server is a Remote Server to hide some part of form
*/
$DBRESULT = $pearDB->query("SELECT i.value FROM informations i WHERE i.key = 'isRemote'");
$isRemote = array_map("myDecode", $DBRESULT->fetchRow());
$result = $DBRESULT->fetchRow();
if ($result === false) {
$isRemote = false;
} else {
$isRemote = array_map("myDecode", $result);
$isRemote = ($isRemote['value'] === 'yes') ? true : false;
}
$DBRESULT->closeCursor();
$isRemote = ($isRemote['value'] === 'yes') ? true : false;

$cct = array();
if (($o == "c" || $o == "w") && $contact_id) {
Expand Down