function __construct() { // Exits on OPTION call $this->_checkCORS(); $this->config = file_get_contents(Config::get('auth')['dataporten']); // Sanity if ($this->config === false) { Response::error(404, 'Not Found: Dataporten config.'); } // Dataporten username and pass $this->config = json_decode($this->config, true); // Exits on incorrect credentials $this->_checkGateKeeperCredentials(); // Make sure we have a scope // (NOTE: 'basic' scope is implicit and not listed in HTTP_X_DATAPORTEN_SCOPES. This means that client MUST have access // to at least ONE extra custom scope). if (!isset($_SERVER["HTTP_X_DATAPORTEN_SCOPES"])) { Response::error(401, 'Unauthorized (missing scope)'); } // Check that we got a username if (!isset($_SERVER["HTTP_X_DATAPORTEN_USERID_SEC"])) { Response::error(401, 'Unauthorized (user not found)'); } // Check if user is member of MediasiteAdmin group $this->isOrgAdmin = $this->_getOrgAdminStatus(); // Check that username exists and is a Feide one... Function will exit if not. //$this->_getFeideUsername(); }
public static function log($text) { if (Config::get('utils')['debug']) { $trace = debug_backtrace(); $caller = $trace[1]; error_log($caller['class'] . $caller['type'] . $caller['function'] . '::' . $caller['line'] . ': ' . $text); } }
private function _loadConfig($configKey) { $this->config = file_get_contents(Config::get('auth')[$configKey]); // Sanity if ($this->config === false) { Response::error(404, 'Not Found: MySQL config [' . $configKey . ']'); } // DB details return json_decode($this->config, true); }
private function getConfig() { $this->config = file_get_contents(Config::get('auth')['relay_sql']); // Sanity if ($this->config === false) { Response::error(404, 'Not Found: SQL config.'); } // Connect username and pass return json_decode($this->config, true); }
### LOAD DEPENDENCIES ### require_once 'relay/autoload.php'; use Relay\Api\Relay; use Relay\Auth\Dataporten; use Relay\Conf\Config; use Relay\Tests\MongoTest; use Relay\Utils\Response; use Relay\Vendor\Router; // Gatekeeper and provider of useful info $dataporten = new Dataporten(); // Provides an interface to SQL, Mongo, FS classes $relay = new Relay($dataporten); ### ALTO ROUTER ### $router = new Router(); $router->addMatchTypes(array('user' => '[0-9A-Za-z.@]++', 'org' => '[0-9A-Za-z.]++', 'presentation' => '[0-9A-Za-z.]++')); $router->setBasePath(Config::get('router')['api_base_path']); // ---------------------- DEFINE ROUTES ---------------------- /** * GET all REST routes */ $router->map('GET', '/', function () { global $router; Response::result(array('status' => true, 'data' => $router->getRoutes())); }, 'All available routes.'); // SERVICE ROUTES $router->addRoutes([array('GET', '/service/version/', function () { global $relay; Response::result(array('status' => true, 'data' => $relay->sql()->getServiceVersion())); }, 'Service version'), array('GET', '/service/info/', function () { global $relay; Response::result(array('status' => true, 'data' => $relay->sql()->getServiceInfo()));