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

Commit

Permalink
fix(CLAPI): check for "Reach API *" fields in user instead of "Reach … (
Browse files Browse the repository at this point in the history
#7117)

* fix(CLAPI): check for "Reach API *" fields in user instead of "Reach Centreon Front-end" when using CLAPI

- remove check for "contact_oreon" field
- remove check for "contact_admin" field
- add check whether at least on of reach_api/reach_api_rt field is active
- fix warning in user form

* fix(typo): do not use fetchRow() twice

* fix(clapi): change check for permissions from reach_api* fields to contact_admin

* fix(enh): move closeCursor() outside of "if" condition
  • Loading branch information
miteto authored Jan 16, 2019
1 parent 9c3f90e commit c989fbf
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 30 deletions.
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

0 comments on commit c989fbf

Please sign in to comment.