From 8ce330c850f45d948fbc987b423ccb72ec6ad96a Mon Sep 17 00:00:00 2001 From: Michael Chan Date: Fri, 24 Mar 2017 16:06:43 +0800 Subject: [PATCH] Update Ion Auth to latest version --- README.md | 2 +- application/config/constants.php | 2 +- application/third_party/ion_auth/README.md | 5 + .../ion_auth/config/ion_auth_default.php | 4 + .../language/arabic/ion_auth_lang.php | 1 + .../language/bulgarian/ion_auth_lang.php | 1 + .../language/catalan/ion_auth_lang.php | 1 + .../language/croatian/ion_auth_lang.php | 1 + .../ion_auth/language/czech/ion_auth_lang.php | 1 + .../language/danish/ion_auth_lang.php | 1 + .../ion_auth/language/dutch/ion_auth_lang.php | 1 + .../language/english/ion_auth_lang.php | 3 +- .../language/estonian/ion_auth_lang.php | 1 + .../ion_auth/language/filipino/auth_lang.php | 144 +++++++++++ .../language/filipino/ion_auth_lang.php | 79 ++++++ .../language/finnish/ion_auth_lang.php | 1 + .../ion_auth/language/french/auth_lang.php | 10 +- .../language/french/ion_auth_lang.php | 1 + .../language/german/ion_auth_lang.php | 1 + .../ion_auth/language/greek/ion_auth_lang.php | 1 + .../language/hungarian/ion_auth_lang.php | 1 + .../language/indonesian/ion_auth_lang.php | 1 + .../language/italian/ion_auth_lang.php | 1 + .../language/japanese/ion_auth_lang.php | 1 + .../language/korean/ion_auth_lang.php | 1 + .../language/lithuanian/ion_auth_lang.php | 1 + .../language/norwegian/ion_auth_lang.php | 1 + .../ion_auth/language/persian/auth_lang.php | 237 +++++++++--------- .../language/persian/ion_auth_lang.php | 32 +-- .../language/pirate/ion_auth_lang.php | 1 + .../language/polish/ion_auth_lang.php | 1 + .../language/portuguese/ion_auth_lang.php | 1 + .../language/romanian/ion_auth_lang.php | 1 + .../language/russian/ion_auth_lang.php | 1 + .../language/slovak/ion_auth_lang.php | 1 + .../language/slovenian/ion_auth_lang.php | 1 + .../language/spanish/ion_auth_lang.php | 1 + .../language/swedish/ion_auth_lang.php | 1 + .../ion_auth/language/thai/ion_auth_lang.php | 1 + .../language/turkish/ion_auth_lang.php | 1 + .../language/ukrainian/ion_auth_lang.php | 81 +++--- .../language/vietnamese/ion_auth_lang.php | 1 + .../ion_auth/language/zh_cn/ion_auth_lang.php | 1 + .../ion_auth/language/zh_tw/ion_auth_lang.php | 1 + .../ion_auth/libraries/Ion_auth.php | 4 +- .../ion_auth/models/Ion_auth_model.php | 97 +++++-- 46 files changed, 522 insertions(+), 211 deletions(-) create mode 100755 application/third_party/ion_auth/language/filipino/auth_lang.php create mode 100755 application/third_party/ion_auth/language/filipino/ion_auth_lang.php diff --git a/README.md b/README.md index 119b509e..a98665e5 100755 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ## CodeIgniter 3 Bootstrap -**Latest Build: 2017-03-18** +**Latest Build: 2017-03-24** **Note: This project is still in progress, but welcome for any issues encountered** diff --git a/application/config/constants.php b/application/config/constants.php index f07420bf..4037aca1 100755 --- a/application/config/constants.php +++ b/application/config/constants.php @@ -105,7 +105,7 @@ } define('CI_BOOTSTRAP_REPO', 'https://github.com/waifung0207/ci_bootstrap_3'); -define('CI_BOOTSTRAP_VERSION', 'Build 20170318'); // will follow semantic version (e.g. v1.x.x) after first stable launch +define('CI_BOOTSTRAP_VERSION', 'Build 20170324'); // will follow semantic version (e.g. v1.x.x) after first stable launch // Upload paths //define('UPLOAD_COVER_PHOTO', 'assets/uploads/cover_photos'); diff --git a/application/third_party/ion_auth/README.md b/application/third_party/ion_auth/README.md index 6ef0e5cf..2b620886 100755 --- a/application/third_party/ion_auth/README.md +++ b/application/third_party/ion_auth/README.md @@ -54,6 +54,11 @@ It is highly recommended that you use encrypted database sessions for security! It is recommended that you add your identity column as a unique index. +###Options +Time Based One-Time Password (TOTP) - +There is a Time Based One-Time Password (TOTP) implementation compatible with Google Authenticator available. Feature branch maintained by [biscofil](https://github.com/biscofil) and is available at [https://github.com/benedmunds/CodeIgniter-Ion-Auth/tree/otp](https://github.com/benedmunds/CodeIgniter-Ion-Auth/tree/otp) + + Feel free to send me an email if you have any problems. diff --git a/application/third_party/ion_auth/config/ion_auth_default.php b/application/third_party/ion_auth/config/ion_auth_default.php index 2760d7df..584946c3 100755 --- a/application/third_party/ion_auth/config/ion_auth_default.php +++ b/application/third_party/ion_auth/config/ion_auth_default.php @@ -99,6 +99,10 @@ $config['maximum_login_attempts'] = 3; // The maximum number of failed login attempts. $config['lockout_time'] = 600; // The number of seconds to lockout an account due to exceeded attempts $config['forgot_password_expiration'] = 0; // The number of milliseconds after which a forgot password request will expire. If set to 0, forgot password requests will not expire. +$config['recheck_timer'] = 0; /* The number of seconds after which the session is checked again against database to see if the user still exists and is active. + Leave 0 if you don't want session recheck. if you really think you need to recheck the session against database, we would + recommend a higher value, as this would affect performance */ + /* | ------------------------------------------------------------------------- diff --git a/application/third_party/ion_auth/language/arabic/ion_auth_lang.php b/application/third_party/ion_auth/language/arabic/ion_auth_lang.php index db2f396b..49da7af3 100755 --- a/application/third_party/ion_auth/language/arabic/ion_auth_lang.php +++ b/application/third_party/ion_auth/language/arabic/ion_auth_lang.php @@ -35,6 +35,7 @@ $lang['deactivate_unsuccessful'] = 'لا يمكن إيقاف حسابك'; $lang['activation_email_successful'] = 'تم إرسال بريد التفعيل'; $lang['activation_email_unsuccessful'] = 'لا يمكن ارسال بريد التفعيل'; +$lang['deactivate_current_user_unsuccessful']= 'You cannot De-Activate your self.'; // Login / Logout $lang['login_successful'] = 'تم تسجيل الدخول بنجاح'; diff --git a/application/third_party/ion_auth/language/bulgarian/ion_auth_lang.php b/application/third_party/ion_auth/language/bulgarian/ion_auth_lang.php index 661c5a57..f53737a7 100755 --- a/application/third_party/ion_auth/language/bulgarian/ion_auth_lang.php +++ b/application/third_party/ion_auth/language/bulgarian/ion_auth_lang.php @@ -37,6 +37,7 @@ $lang['deactivate_unsuccessful'] = 'Неуспешен опит за деактивиране на регистрацията'; $lang['activation_email_successful'] = 'Изпратен е Email за активиране на регистрацията'; $lang['activation_email_unsuccessful'] = 'Неуспешен опит за изпращане на Email за активация'; +$lang['deactivate_current_user_unsuccessful']= 'You cannot De-Activate your self.'; // Login / Logout $lang['login_successful'] = 'Успешен вход в системата'; diff --git a/application/third_party/ion_auth/language/catalan/ion_auth_lang.php b/application/third_party/ion_auth/language/catalan/ion_auth_lang.php index af0edd43..967b8440 100755 --- a/application/third_party/ion_auth/language/catalan/ion_auth_lang.php +++ b/application/third_party/ion_auth/language/catalan/ion_auth_lang.php @@ -40,6 +40,7 @@ $lang['deactivate_unsuccessful'] = 'No ha estat possible desactivar el compte'; $lang['activation_email_successful'] = 'Email d'activació enviat'; $lang['activation_email_unsuccessful'] = 'No ha estat possible enviar l'email d'activació'; +$lang['deactivate_current_user_unsuccessful']= 'You cannot De-Activate your self.'; // Login / Logout $lang['login_successful'] = 'Sessió iniciada amb èxit'; diff --git a/application/third_party/ion_auth/language/croatian/ion_auth_lang.php b/application/third_party/ion_auth/language/croatian/ion_auth_lang.php index 757c3d64..12d80e88 100755 --- a/application/third_party/ion_auth/language/croatian/ion_auth_lang.php +++ b/application/third_party/ion_auth/language/croatian/ion_auth_lang.php @@ -40,6 +40,7 @@ $lang['deactivate_unsuccessful'] = 'De-aktivacija računa noje uspjela'; $lang['activation_email_successful'] = 'Email za aktivaciju je poslan'; $lang['activation_email_unsuccessful'] = 'Slanje mail za aktivaciju nije uspjelo'; +$lang['deactivate_current_user_unsuccessful']= 'You cannot De-Activate your self.'; // Login / Logout $lang['login_successful'] = 'Uspješno prijavljeni'; diff --git a/application/third_party/ion_auth/language/czech/ion_auth_lang.php b/application/third_party/ion_auth/language/czech/ion_auth_lang.php index 3ef87f46..b7c15bfe 100755 --- a/application/third_party/ion_auth/language/czech/ion_auth_lang.php +++ b/application/third_party/ion_auth/language/czech/ion_auth_lang.php @@ -35,6 +35,7 @@ $lang['deactivate_unsuccessful'] = 'Nelze deaktivován účet'; $lang['activation_email_successful'] = 'Aktivační e-mail byl odeslán'; $lang['activation_email_unsuccessful'] = 'Nelze odeslat aktivační e-mail'; +$lang['deactivate_current_user_unsuccessful']= 'You cannot De-Activate your self.'; // Login / Logout $lang['login_successful'] = 'Úspěšně přihlášen'; diff --git a/application/third_party/ion_auth/language/danish/ion_auth_lang.php b/application/third_party/ion_auth/language/danish/ion_auth_lang.php index 13f7225e..c2fd9b55 100755 --- a/application/third_party/ion_auth/language/danish/ion_auth_lang.php +++ b/application/third_party/ion_auth/language/danish/ion_auth_lang.php @@ -30,6 +30,7 @@ $lang['deactivate_unsuccessful'] = 'Det var ikke muligt at deaktivere kontoen'; $lang['activation_email_successful'] = 'Email vedrørende aktivering af konto er afsendt'; $lang['activation_email_unsuccessful'] = 'Det var ikke muligt at sende email vedrørende aktivering af konto'; +$lang['deactivate_current_user_unsuccessful']= 'You cannot De-Activate your self.'; // Login / Logout $lang['login_successful'] = 'Logged ind'; $lang['login_unsuccessful'] = 'Ugyldigt login'; diff --git a/application/third_party/ion_auth/language/dutch/ion_auth_lang.php b/application/third_party/ion_auth/language/dutch/ion_auth_lang.php index 02700c8d..782d4db5 100755 --- a/application/third_party/ion_auth/language/dutch/ion_auth_lang.php +++ b/application/third_party/ion_auth/language/dutch/ion_auth_lang.php @@ -39,6 +39,7 @@ $lang['deactivate_unsuccessful'] = 'Accound deactiveren is mislukt'; $lang['activation_email_successful'] = 'Activatie e-mail is verzonden'; $lang['activation_email_unsuccessful'] = 'Activatie e-mail verzenden is mislukt'; +$lang['deactivate_current_user_unsuccessful']= 'You cannot De-Activate your self.'; // Login / Logout $lang['login_successful'] = 'U bent ingelogd'; diff --git a/application/third_party/ion_auth/language/english/ion_auth_lang.php b/application/third_party/ion_auth/language/english/ion_auth_lang.php index 9c335feb..06f8e2a7 100755 --- a/application/third_party/ion_auth/language/english/ion_auth_lang.php +++ b/application/third_party/ion_auth/language/english/ion_auth_lang.php @@ -27,7 +27,7 @@ $lang['password_change_successful'] = 'Password Successfully Changed'; $lang['password_change_unsuccessful'] = 'Unable to Change Password'; $lang['forgot_password_successful'] = 'Password Reset Email Sent'; -$lang['forgot_password_unsuccessful'] = 'Unable to Reset Password'; +$lang['forgot_password_unsuccessful'] = 'Unable to email the Reset Password link'; // Activation $lang['activate_successful'] = 'Account Activated'; @@ -36,6 +36,7 @@ $lang['deactivate_unsuccessful'] = 'Unable to De-Activate Account'; $lang['activation_email_successful'] = 'Activation Email Sent. Please check your inbox or spam'; $lang['activation_email_unsuccessful'] = 'Unable to Send Activation Email'; +$lang['deactivate_current_user_unsuccessful']= 'You cannot De-Activate your self.'; // Login / Logout $lang['login_successful'] = 'Logged In Successfully'; diff --git a/application/third_party/ion_auth/language/estonian/ion_auth_lang.php b/application/third_party/ion_auth/language/estonian/ion_auth_lang.php index 185c7209..c2cb5c68 100755 --- a/application/third_party/ion_auth/language/estonian/ion_auth_lang.php +++ b/application/third_party/ion_auth/language/estonian/ion_auth_lang.php @@ -38,6 +38,7 @@ $lang['deactivate_unsuccessful'] = 'Konto aktiveerimine ebaõnnestus.'; $lang['activation_email_successful'] = 'Sinu e-postile saadeti kiri edasise juhendiga.'; $lang['activation_email_unsuccessful'] = 'Aktiveerimiskirja saatmine ebaõnnestus.'; +$lang['deactivate_current_user_unsuccessful']= 'You cannot De-Activate your self.'; // Login / Logout $lang['login_successful'] = 'Oled sisse logitud'; diff --git a/application/third_party/ion_auth/language/filipino/auth_lang.php b/application/third_party/ion_auth/language/filipino/auth_lang.php new file mode 100755 index 00000000..f1c0bf96 --- /dev/null +++ b/application/third_party/ion_auth/language/filipino/auth_lang.php @@ -0,0 +1,144 @@ +load->config('ion_auth', TRUE); + $this->config->load('ion_auth', TRUE); $this->load->library(array('email')); $this->lang->load('ion_auth'); $this->load->helper(array('cookie', 'language','url')); @@ -443,7 +443,7 @@ public function logged_in() { $this->ion_auth_model->trigger_events('logged_in'); - return (bool) $this->session->userdata('identity'); + return $this->ion_auth_model->recheck_session(); } /** diff --git a/application/third_party/ion_auth/models/Ion_auth_model.php b/application/third_party/ion_auth/models/Ion_auth_model.php index 3448a6f8..fbd60655 100755 --- a/application/third_party/ion_auth/models/Ion_auth_model.php +++ b/application/third_party/ion_auth/models/Ion_auth_model.php @@ -165,7 +165,7 @@ public function __construct() { parent::__construct(); $this->load->database(); - $this->load->config('ion_auth', TRUE); + $this->config->load('ion_auth', TRUE); $this->load->helper('cookie'); $this->load->helper('date'); $this->lang->load('ion_auth'); @@ -374,12 +374,19 @@ public function salt() $buffer = ''; $buffer_valid = false; - if (function_exists('mcrypt_create_iv') && !defined('PHALANGER')) { - $buffer = mcrypt_create_iv($raw_salt_len, MCRYPT_DEV_URANDOM); - if ($buffer) { - $buffer_valid = true; - } - } + if (function_exists('random_bytes')) { + $buffer = random_bytes($raw_salt_len); + if ($buffer) { + $buffer_valid = true; + } + } + + if (!$buffer_valid && function_exists('mcrypt_create_iv') && !defined('PHALANGER')) { + $buffer = mcrypt_create_iv($raw_salt_len, MCRYPT_DEV_URANDOM); + if ($buffer) { + $buffer_valid = true; + } + } if (!$buffer_valid && function_exists('openssl_random_pseudo_bytes')) { $buffer = openssl_random_pseudo_bytes($raw_salt_len); @@ -517,6 +524,11 @@ public function deactivate($id = NULL) $this->set_error('deactivate_unsuccessful'); return FALSE; } + elseif($this->ion_auth->logged_in() && $this->user()->row()->id == $id) + { + $this->set_error('deactivate_current_user_unsuccessful'); + return FALSE; + } $activation_code = sha1(md5(microtime())); $this->activation_code = $activation_code; @@ -1022,6 +1034,51 @@ public function login($identity, $password, $remember=FALSE) return FALSE; } + /** + * recheck_session verifies if the session should be rechecked according to + * the configuration item recheck_timer. If it does, then it will check if the user is still active + * @return bool + */ + public function recheck_session() + { + $recheck = (null !== $this->config->item('recheck_timer', 'ion_auth')) ? $this->config->item('recheck_timer', 'ion_auth') : 0; + + if($recheck!==0) + { + $last_login = $this->session->userdata('last_check'); + if($last_login+$recheck < time()) + { + $query = $this->db->select('id') + ->where(array($this->identity_column=>$this->session->userdata('identity'),'active'=>'1')) + ->limit(1) + ->order_by('id', 'desc') + ->get($this->tables['users']); + if ($query->num_rows() === 1) + { + $this->session->set_userdata('last_check',time()); + } + else + { + $this->trigger_events('logout'); + + $identity = $this->config->item('identity', 'ion_auth'); + + if (substr(CI_VERSION, 0, 1) == '2') + { + $this->session->unset_userdata( array($identity => '', 'id' => '', 'user_id' => '') ); + } + else + { + $this->session->unset_userdata( array($identity, 'id', 'user_id') ); + } + return false; + } + } + } + + return (bool) $this->session->userdata('identity'); + } + /** * is_max_login_attempts_exceeded * Based on code from Tank Auth, by Ilya Konyukhov (https://github.com/ilkon/Tank-Auth) @@ -1164,15 +1221,11 @@ public function like($like, $value = NULL, $position = 'both') { $this->trigger_events('like'); - if (!is_array($like)) - { - $like = array($like => array( - 'value' => $value, - 'position' => $position, - )); - } - - array_push($this->_ion_like, $like); + array_push($this->_ion_like, array( + 'like' => $like, + 'value' => $value, + 'position' => $position + )); return $this; } @@ -1328,7 +1381,7 @@ public function users($groups = NULL) { foreach ($this->_ion_like as $like) { - $this->db->or_like($like); + $this->db->or_like($like['like'], $like['value'], $like['position']); } $this->_ion_like = array(); @@ -1638,11 +1691,6 @@ public function delete_user($id) // delete user from users table should be placed after remove from group $this->db->delete($this->tables['users'], array('id' => $id)); - // if user does not exist in database then it returns FALSE else removes the user from groups - if ($this->db->affected_rows() <= 0) - { - return FALSE; - } if ($this->db->trans_status() === FALSE) { @@ -1724,7 +1772,8 @@ public function set_session($user) $this->identity_column => $user->{$this->identity_column}, 'email' => $user->email, 'user_id' => $user->id, //everyone likes to overwrite id so we'll use user_id - 'old_last_login' => $user->last_login + 'old_last_login' => $user->last_login, + 'last_check' => time(), ); $this->session->set_userdata($session_data); @@ -1810,7 +1859,7 @@ public function login_remembered_user() // get the user $this->trigger_events('extra_where'); $query = $this->db->select($this->identity_column.', id, email, last_login') - ->where($this->identity_column, url_decode(get_cookie($this->config->item('identity_cookie_name', 'ion_auth')))) + ->where($this->identity_column, urldecode(get_cookie($this->config->item('identity_cookie_name', 'ion_auth')))) ->where('remember_code', get_cookie($this->config->item('remember_cookie_name', 'ion_auth'))) ->limit(1) ->order_by('id', 'desc')