use Directus\Db\TableSchema; // use Directus\Files; // use Directus\Files\Upload; use Directus\MemcacheProvider; use Directus\Util; use Directus\View\JsonView; use Directus\View\ExceptionView; use Directus\Db\TableGateway\DirectusIPWhitelist; use Zend\Db\Sql\Expression; // API Version shortcut for routes: $v = API_VERSION; /** * Slim App & Directus Providers */ $app = Bootstrap::get('app'); $requestNonceProvider = new RequestNonceProvider(); /** * Catch user-related exceptions & produce client responses. */ $app->config('debug', false); $exceptionView = new ExceptionView(); $exceptionHandler = function (\Exception $exception) use($app, $exceptionView) { $exceptionView->exceptionHandler($app, $exception); }; $app->error($exceptionHandler); // // Catch runtime erros etc. as well // set_exception_handler($exceptionHandler); // Routes which do not need protection by the authentication and the request // nonce enforcement. $authAndNonceRouteWhitelist = array("auth_login", "auth_logout", "auth_session", "auth_clear_session", "auth_nonces", "auth_permissions", "debug_acl_poc"); $app->hook('slim.before.dispatch', function () use($app, $requestNonceProvider, $authAndNonceRouteWhitelist) {
use Directus\Util\ArrayUtils; use Directus\Util\DateUtils; use Directus\Util\SchemaUtils; use Directus\Util\StringUtils; use Directus\View\ExceptionView; use Directus\View\JsonView; // use Directus\Files; // use Directus\Files\Upload; // use Directus\Db\TableGateway\DirectusIPWhitelist; // API Version shortcut for routes: $v = API_VERSION; /** * Slim App & Directus Providers */ $app = Bootstrap::get('app'); $requestNonceProvider = new RequestNonceProvider(); /** * Load Registered Hooks */ $config = Bootstrap::get('config'); if (array_key_exists('hooks', $config)) { load_registered_hooks($config['hooks'], false); } if (array_key_exists('filters', $config)) { // set seconds parameter "true" to add as filters load_registered_hooks($config['filters'], true); } /** * Catch user-related exceptions & produce client responses. */ $app->config('debug', false);
function getNonces() { $requestNonceProvider = new RequestNonceProvider(); $nonces = array_merge($requestNonceProvider->getOptions(), array('pool' => $requestNonceProvider->getAllNonces())); return $nonces; }
// use Directus\Files; // use Directus\Files\Upload; use Directus\Mail\Mail; use Directus\MemcacheProvider; use Directus\Util; use Directus\View\JsonView; use Directus\View\ExceptionView; // use Directus\Db\TableGateway\DirectusIPWhitelist; use Zend\Db\Sql\Expression; // API Version shortcut for routes: $v = API_VERSION; /** * Slim App & Directus Providers */ $app = Bootstrap::get('app'); $requestNonceProvider = new RequestNonceProvider(); /** * Catch user-related exceptions & produce client responses. */ $app->config('debug', false); $exceptionView = new ExceptionView(); $exceptionHandler = function (\Exception $exception) use($app, $exceptionView) { $exceptionView->exceptionHandler($app, $exception); }; $app->error($exceptionHandler); // // Catch runtime erros etc. as well // set_exception_handler($exceptionHandler); // Routes which do not need protection by the authentication and the request // nonce enforcement. $authAndNonceRouteWhitelist = array("auth_login", "auth_logout", "auth_session", "auth_clear_session", "auth_nonces", "auth_reset_password", "auth_permissions", "debug_acl_poc"); $app->hook('slim.before.dispatch', function () use($app, $requestNonceProvider, $authAndNonceRouteWhitelist) {