From 85396efcf9f66b927b27ceb38bf38131bd69b0e0 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Sun, 24 Apr 2016 16:38:26 +0900 Subject: [PATCH] Ensure that the auth key is always available --- modules/admin/admin.admin.view.php | 35 ++++++++++++++++++++++++++ modules/install/install.controller.php | 5 ++++ 2 files changed, 40 insertions(+) diff --git a/modules/admin/admin.admin.view.php b/modules/admin/admin.admin.view.php index 9703144ae..7bc617e75 100644 --- a/modules/admin/admin.admin.view.php +++ b/modules/admin/admin.admin.view.php @@ -50,10 +50,45 @@ class adminAdminView extends admin $this->makeGnbUrl(); + // Check system configuration + $this->checkSystemConfiguration(); + // Retrieve the list of installed modules $this->checkEasyinstall(); } + /** + * check system configuration + * @return void + */ + function checkSystemConfiguration() + { + $changed = false; + + // Check encryption keys. + if (config('crypto.encryption_key') === null) + { + config('crypto.encryption_key', Rhymix\Framework\Security::getRandom(64, 'alnum')); + $changed = true; + } + if (config('crypto.authentication_key') === null) + { + config('crypto.authentication_key', Rhymix\Framework\Security::getRandom(64, 'alnum')); + $changed = true; + } + if (config('crypto.session_key') === null) + { + config('crypto.session_key', Rhymix\Framework\Security::getRandom(64, 'alnum')); + $changed = true; + } + + // Save new configuration. + if ($changed) + { + Rhymix\Framework\Config::save(); + } + } + /** * check easy install * @return void diff --git a/modules/install/install.controller.php b/modules/install/install.controller.php index c5f45d224..1a8ce38bd 100644 --- a/modules/install/install.controller.php +++ b/modules/install/install.controller.php @@ -149,6 +149,11 @@ class installController extends install $config['db']['master']['prefix'] .= '_'; } + // Create new crypto keys. + $config['crypto']['encryption_key'] = Rhymix\Framework\Security::getRandom(64, 'alnum'); + $config['crypto']['authentication_key'] = Rhymix\Framework\Security::getRandom(64, 'alnum'); + $config['crypto']['session_key'] = Rhymix\Framework\Security::getRandom(64, 'alnum'); + // Set the default language. $config['locale']['default_lang'] = Context::getLangType(); $config['locale']['enabled_lang'] = array($config['locale']['default_lang']);