/** * Index Action * */ public function indexAction() { $this->tag->setTitle(__('Admin panel')); $this->tag->setTitle(__('Admin panel')); /** * This code will benchmark your server to determine how high of a cost you can * afford. You want to set the highest cost that you can without slowing down * you server too much. 8-10 is a good baseline, and more is good if your servers * are fast enough. The code below aims for ≤ 50 milliseconds stretching time, * which is a good baseline for systems handling interactive logins. */ $timeTarget = 0.05; // 50 milliseconds $costPhp = 8; do { $costPhp++; $start = microtime(true); password_hash("test", PASSWORD_BCRYPT, ["cost" => $costPhp]); $end = microtime(true); } while ($end - $start < $timeTarget); //echo "Appropriate Cost Found: " . $cost . "\n"; $this->view->setVar('costPhp', $costPhp); $costPhal = 8; do { $costPhal++; $start = microtime(true); $security = new \Phalcon\Security(); //$security->setDefaultHash($this->config->security->key); $security->setWorkFactor($costPhal); $security->setDefaultHash(\Phalcon\Security::CRYPT_BLOWFISH_Y); $security->hash("test"); $end = microtime(true); } while ($end - $start < $timeTarget); $this->view->setVar('costPhal', $costPhal); }
public function setSecur() { $this->set('security', function () { $security = new \Phalcon\Security(); //Устанавливаем фактор хеширования в 12 раундов $security->setWorkFactor(12); return $security; }, true); }
$di->set('flashSession', function () { $flash = new \Phalcon\Flash\Session(array('error' => 'alert alert-danger', 'success' => 'alert alert-success', 'notice' => 'alert alert-info', 'warning' => 'alert alert-warning')); return $flash; }); /*$di->set( 'dispatcher', function () { $dispatcher = new MvcDispatcher(); $dispatcher->setDefaultNamespace('reportingtool\Controllers'); return $dispatcher; } );*/ $di->set('security', function () { $security = new Phalcon\Security(); //Set the password hashing factor to 12 rounds $security->setWorkFactor(12); return $security; }, true); /** * View cache */ $di->set('viewCache', function () use($config) { $frontCache = new \Phalcon\Cache\Frontend\None(); return new Phalcon\Cache\Backend\Memory($frontCache); if ($config->application->debug) { } else { //Cache data for one day by default $frontCache = new \Phalcon\Cache\Frontend\Output(array("lifetime" => 86400 * 30)); return new FileCache($frontCache, array("cacheDir" => APP_PATH . "/app/cache/views/", "prefix" => "reportingtool-cache-")); } });
}); // Ruta de APP $apppath = realpath('../'); $di->set('appPath', function () use($apppath) { $obj = new \stdClass(); $obj->path = $apppath; return $obj; }); $path = new \stdClass(); $path->path = $config->general->path; $path->tmpfolder = $config->general->tmp; $di->set('path', $path); $di->set('hash', function () { $hash = new \Phalcon\Security(); //Set the password hashing factor to 12 rounds $hash->setWorkFactor(12); return $hash; }, true); /* * Este objeto contiene los datos de ubicación del banco de imágenes */ $imgbnk = new \stdClass(); $imgbnk->loginimages = $config->imagebank->loginimages; $imgbnk->appimages = $config->imagebank->appimages; $imgbnk->userdir = $config->imagebank->userdir; $imgbnk->systemsize = $config->imagebank->systemsize; $imgbnk->dirname = $config->imagebank->dirname; $imgbnk->relativeloginimages = $config->imagebank->relativeloginimages; $imgbnk->relativeappimages = $config->imagebank->relativeappimages; $imgbnk->relativeuserdir = $config->imagebank->relativeuserdir; $di->set('imgbnk', $imgbnk);
/** * Set the security service * * @return void */ protected function security() { $config = $this->_config; $this->_di->set('security', function () use($config) { $security = new \Phalcon\Security(); $security->setWorkFactor($config->auth->hash_workload); $security->setDefaultHash(\Phalcon\Security::CRYPT_BLOWFISH_Y); return $security; }); }
/** * Hash para validacion y creacion de contraseñas de los usuarios * @return DI object */ private function setSecurityHash() { $this->di->set('hash', function () { $hash = new \Phalcon\Security(); //Set the password hashing factor to 12 rounds $hash->setWorkFactor(12); return $hash; }, true); }