More Updates for Oauth support
This commit is contained in:
@@ -35,6 +35,8 @@ class PmSessionHandler //implements SessionHandlerInterface
|
||||
*/
|
||||
private $httponly = true;
|
||||
|
||||
private $debug = false;
|
||||
|
||||
/**
|
||||
* The Construct
|
||||
* Initialize object and set database credentials passed as arguments
|
||||
@@ -129,7 +131,7 @@ class PmSessionHandler //implements SessionHandlerInterface
|
||||
// routines moved to __construct() for php 5.3.x compatibility
|
||||
|
||||
|
||||
error_log("PmSession :: open($savePath, $sessionName) was called");
|
||||
$this->log("open($savePath, $sessionName) was called");
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -150,7 +152,7 @@ class PmSessionHandler //implements SessionHandlerInterface
|
||||
// this was commented to take advantage of PDO persistence connections
|
||||
//$this->db = null;
|
||||
|
||||
error_log("PmSession :: close() was called");
|
||||
$this->log("close() was called");
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -176,7 +178,7 @@ class PmSessionHandler //implements SessionHandlerInterface
|
||||
//$this->wstmt->bind_param('siss', $id, $time, $data, $key);
|
||||
$this->wstmt->execute(array($id, $time, $data, $key));
|
||||
|
||||
error_log("PmSession :: write($id, array()) was called");
|
||||
$this->log("write($id, array()) was called");
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -197,7 +199,7 @@ class PmSessionHandler //implements SessionHandlerInterface
|
||||
$data = $this->rstmt->fetch();
|
||||
$data = unserialize(base64_decode($data['DATA']));
|
||||
|
||||
error_log("PmSession :: read($id) was called");
|
||||
$this->log("read($id) was called");
|
||||
|
||||
return $data;
|
||||
}
|
||||
@@ -213,7 +215,7 @@ class PmSessionHandler //implements SessionHandlerInterface
|
||||
$this->dstmt = $this->db->prepare("DELETE FROM {$this->dbtable} WHERE ID = ?");
|
||||
}
|
||||
|
||||
error_log("PmSession :: destroy($id) was called");
|
||||
$this->log("destroy($id) was called");
|
||||
|
||||
$this->dstmt->execute(array($id));
|
||||
|
||||
@@ -236,8 +238,17 @@ class PmSessionHandler //implements SessionHandlerInterface
|
||||
|
||||
$this->gcstmt->execute(array($time));
|
||||
|
||||
error_log("PmSession :: gc($maxlifetime) was called");
|
||||
$this->log("gc($maxlifetime) was called");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function log($data)
|
||||
{
|
||||
if (! $this->debug) {
|
||||
return false;
|
||||
}
|
||||
|
||||
error_log('PM Session Handler :: ' . print_r($data, true));
|
||||
}
|
||||
}
|
||||
@@ -18,16 +18,26 @@ class Bootstrap
|
||||
|
||||
public static function autoloadClass($class)
|
||||
{
|
||||
//error_log( "$class ");
|
||||
$className = strtolower($class);
|
||||
|
||||
if (array_key_exists($className, BootStrap::$includeClassPaths)) {
|
||||
require_once BootStrap::$includeClassPaths[$className];
|
||||
|
||||
return true;
|
||||
} else {
|
||||
//print "$class "; //die;
|
||||
//print_r ( debug_backtrace(false));
|
||||
// try resolve a Model class file
|
||||
$classFile = PATH_CORE . 'classes' . PATH_SEP . 'model' . PATH_SEP . $class . '.php';
|
||||
|
||||
if (file_exists($classFile)) {
|
||||
require_once $classFile;
|
||||
|
||||
return true;
|
||||
} else {
|
||||
//error_log(' ==> CLass not found: ' . $class);
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function registerClass($classname, $includeFile)
|
||||
|
||||
@@ -3,16 +3,12 @@ namespace Api\OAuth2;
|
||||
|
||||
use Luracast\Restler\iAuthenticate;
|
||||
|
||||
use OAuth2_Request;
|
||||
use OAuth2_Response;
|
||||
use OAuth2_GrantType_AuthorizationCode;
|
||||
use OAuth2_Storage_Pdo;
|
||||
use OAuth2_Server;
|
||||
|
||||
/**
|
||||
* Class Server
|
||||
*
|
||||
* @package OAuth2
|
||||
* @author Erik Amaru Ortiz <aortiz.erik at gmail dot com>
|
||||
*
|
||||
*/
|
||||
class Server implements iAuthenticate
|
||||
@@ -25,12 +21,10 @@ class Server implements iAuthenticate
|
||||
* @var OAuth2_Storage_Pdo
|
||||
*/
|
||||
protected $storage;
|
||||
|
||||
protected $scope = array();
|
||||
|
||||
protected static $pmClientId;
|
||||
protected static $userId;
|
||||
|
||||
protected static $dbUser;
|
||||
protected static $dbPassword;
|
||||
protected static $dsn;
|
||||
@@ -120,7 +114,9 @@ class Server implements iAuthenticate
|
||||
*
|
||||
*
|
||||
* @param bool $authorize
|
||||
*
|
||||
* @param string $userId optional user id
|
||||
* @param bool $returnResponse optional flag to specify if the function should return the Response object
|
||||
* @return \OAuth2\ResponseInterface
|
||||
* @format JsonFormat,UploadFormat
|
||||
*/
|
||||
public function postAuthorize($authorize = false, $userId = null, $returnResponse = false)
|
||||
@@ -194,11 +190,12 @@ class Server implements iAuthenticate
|
||||
|
||||
self::$userId = $token['user_id'];
|
||||
|
||||
// verify if the client is our local PM Designer client
|
||||
// verify if the client is not our local PM Designer client
|
||||
if ($token['client_id'] != self::getPmClientId()) {
|
||||
return $allowed;
|
||||
}
|
||||
|
||||
// making a partcular session verification for PM Web Designer Client
|
||||
if (! isset($_SESSION) || ! array_key_exists('USER_LOGGED', $_SESSION)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user