Skip to content

Commit

Permalink
yet another security breach
Browse files Browse the repository at this point in the history
  • Loading branch information
Praesidiarius committed Apr 29, 2021
1 parent e86193e commit 386142a
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/Controller/ApiController.php
Expand Up @@ -53,6 +53,24 @@ public function __construct(AdapterInterface $oDbAdapter, UserTable $oTableGatew
$this->sSingleForm = 'apikey-single';
}

protected function checkApiKey() {
$bCheck = true;
if(!isset($_REQUEST['authkey'])) {
$bCheck = false;
} else {
$sKey = filter_var($_REQUEST['authkey'], FILTER_SANITIZE_STRING);
$oKeyTbl = $this->getCustomTable('core_api_key');
$oKeyFound = $oKeyTbl->select(['api_key' => $sKey]);
if(count($oKeyFound) > 0) {

} else {
$bCheck = false;
}
}

return $bCheck;
}

/**
* API Home - Main Index
*
Expand All @@ -61,6 +79,10 @@ public function __construct(AdapterInterface $oDbAdapter, UserTable $oTableGatew
*/
public function indexAction()
{
$bCheck = $this->checkApiKey();
if($bCheck == false) {
return $this->redirect()->toRoute('login');
}
$this->layout('layout/json');

$aReturn = ['state' => 'success','message' => 'Welcome to onePlace User API'];
Expand Down Expand Up @@ -170,6 +192,10 @@ public function manageAction()
*/
public function listAction()
{
$bCheck = $this->checkApiKey();
if($bCheck == false) {
return $this->redirect()->toRoute('login');
}
$this->layout('layout/json');

# Set default values
Expand Down Expand Up @@ -297,6 +323,10 @@ public function listAction()
*/
public function getAction()
{
$bCheck = $this->checkApiKey();
if($bCheck == false) {
return $this->redirect()->toRoute('login');
}
$this->layout('layout/json');

# Get Skeleton ID from route
Expand Down Expand Up @@ -333,6 +363,11 @@ private function generateKey()

public function finishsetupAction()
{
$bCheck = $this->checkApiKey();
if($bCheck == false) {
return $this->redirect()->toRoute('login');
}

$this->layout('layout/json');

$sSystemName = $this->params()->fromRoute('systemkey', '');
Expand Down

0 comments on commit 386142a

Please sign in to comment.