diff --git a/module/VuFind/config/module.config.php b/module/VuFind/config/module.config.php index d3e0764976e6742090c4d431e3d8dae5da027d81..58f1c6d3549f33d5044d82d51a8f8dcaca23b22a 100644 --- a/module/VuFind/config/module.config.php +++ b/module/VuFind/config/module.config.php @@ -576,7 +576,8 @@ $staticRoutes = array( 'Cover/Show', 'Cover/Unavailable', 'Error/Unavailable', 'Help/Home', 'Install/Done', 'Install/FixBasicConfig', 'Install/FixCache', 'Install/FixDatabase', 'Install/FixDependencies', 'Install/FixILS', - 'Install/FixSolr', 'Install/Home', 'Install/ShowSQL', 'Install/FixSecurity', + 'Install/FixSecurity', 'Install/FixSolr', 'Install/Home', + 'Install/PerformSecurityFix', 'Install/ShowSQL', 'MyResearch/Account', 'MyResearch/CheckedOut', 'MyResearch/Delete', 'MyResearch/DeleteList', 'MyResearch/Edit', 'MyResearch/Email', 'MyResearch/Export', 'MyResearch/Favorites', 'MyResearch/Fines', diff --git a/module/VuFind/src/VuFind/Controller/InstallController.php b/module/VuFind/src/VuFind/Controller/InstallController.php index 939cae2d5601cf1d7fb24a0fea7f679efd0d6459..618240308d757da257dda9afc06ab9f53e5359a1 100644 --- a/module/VuFind/src/VuFind/Controller/InstallController.php +++ b/module/VuFind/src/VuFind/Controller/InstallController.php @@ -636,6 +636,33 @@ class InstallController extends AbstractBase * @return mixed */ public function fixsecurityAction() + { + // If the user doesn't want to proceed, abort now: + $userConfirmation = $this->params()->fromPost('fix-user-table', 'Unset'); + if ($userConfirmation == 'No') { + $msg = 'Security upgrade aborted.'; + $this->flashMessenger()->setNamespace('error')->addMessage($msg); + return $this->redirect()->toRoute('install-home'); + } + + // If we don't need to prompt the user, or if they confirmed, do the fix: + $rows = $this->getTable('user')->getInsecureRows(); + if (count($rows) == 0 || $userConfirmation == 'Yes') { + return $this->forwardTo('Install', 'performsecurityfix'); + } + + // If we got this far, we need to ask permission to proceed: + $view = $this->createViewModel(); + $view->confirmUserFix = true; + return $view; + } + + /** + * Perform fix for Security problems. + * + * @return mixed + */ + public function performsecurityfixAction() { // First, set encryption/hashing to true, and set the key $config = ConfigReader::getConfig(); @@ -648,13 +675,15 @@ class InstallController extends AbstractBase } // Success? Redirect to this action in order to reload the configuration: - return $this->redirect()->toRoute('install-fixsecurity'); + return $this->redirect()->toRoute('install-performsecurityfix'); } // Now we want to loop through the database and update passwords (if // necessary). $rows = $this->getTable('user')->getInsecureRows(); if (count($rows) > 0) { + // If we got this far, the user POSTed their confirmation -- go ahead + // with the fix: $bcrypt = new Bcrypt(); foreach ($rows as $row) { if ($row->password != '') { @@ -667,6 +696,8 @@ class InstallController extends AbstractBase $row->save(); } } + $msg = count($rows) . ' user row(s) encrypted.'; + $this->flashMessenger()->setNamespace('info')->addMessage($msg); } return $this->redirect()->toRoute('install-home'); } diff --git a/themes/blueprint/templates/install/fixsecurity.phtml b/themes/blueprint/templates/install/fixsecurity.phtml new file mode 100644 index 0000000000000000000000000000000000000000..b2d117a0f6eac19fc53ed39fa1524b19615a0b5f --- /dev/null +++ b/themes/blueprint/templates/install/fixsecurity.phtml @@ -0,0 +1,27 @@ +<? + // Set page title. + $this->headTitle($this->translate('auto_configure_title')); + + // Set up breadcrumbs: + $this->layout()->breadcrumbs = '<a href="' . $this->url('install-home') .'">' . $this->transEsc('auto_configure_title') . '</a>'; +?> +<h1><?=$this->transEsc('auto_configure_title')?></h1> + +<?=$this->flashmessages()?> + +<? if (isset($this->confirmUserFix) && $this->confirmUserFix): ?> + <p>You have existing user data in your database containing non-encrypted passwords.</p> + <p>If you continue with enabling security, all of your passwords will be hashed and/or encrypted.</p> + <p><b>Please make a database backup before proceeding.</b></p> + <p>You should <b>NOT</b> turn on encryption if you still wish for your database to be compatible with VuFind 1.x. If you want + to keep the option of being able to roll back to the earlier version, or if you plan on temporarily running 1.x and 2.x in + parallel, you should not enable encryption now. + </p> + <p><i>Do you still wish to proceed with enabling enhanced security in the database?</i></p> + <form method="post" action="<?=$this->url('install-fixsecurity')?>"> + <input type="submit" name="fix-user-table" value="Yes" /> + <input type="submit" name="fix-user-table" value="No" /> + </form> +<? else: ?> + <p>No security problems found.</p> +<? endif; ?> diff --git a/themes/blueprint/templates/install/home.phtml b/themes/blueprint/templates/install/home.phtml index f34e504b426be7c855868bfcd456d18a9a1201ce..5191faa09489b2a10c0cf1e3d468e962282bc30d 100644 --- a/themes/blueprint/templates/install/home.phtml +++ b/themes/blueprint/templates/install/home.phtml @@ -6,6 +6,7 @@ $this->layout()->breadcrumbs = '<em>' . $this->transEsc('auto_configure_title') . '</em>'; ?> <h1><?=$this->transEsc('auto_configure_title')?></h1> +<?=$this->flashmessages()?> <ul> <? $errors = 0; foreach ($this->checks as $check): ?> <? if (!$check['status']) $errors++; ?>