From 359e28a50f990fb205c62532f495b48454a6787c Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Mon, 10 Nov 2008 16:45:06 +0000 Subject: Remove Auth module --- modules/auth/config/auth.php | 37 ------- modules/auth/config/basic_auth.php | 35 ------ modules/auth/css/login.css | 44 -------- modules/auth/helpers/auth_installer.php | 62 ----------- modules/auth/js/login.js | 68 ------------ modules/auth/libraries/Auth.php | 88 --------------- modules/auth/libraries/drivers/Auth.php | 37 ------- modules/auth/libraries/drivers/Auth/Basic.php | 146 ------------------------- modules/auth/models/password.php | 22 ---- modules/auth/tests/Auth_Installer_Test.php | 36 ------ modules/auth/views/login.html.php | 26 ----- modules/gallery_unit_test/controllers/test.php | 2 - 12 files changed, 603 deletions(-) delete mode 100644 modules/auth/config/auth.php delete mode 100644 modules/auth/config/basic_auth.php delete mode 100644 modules/auth/css/login.css delete mode 100644 modules/auth/helpers/auth_installer.php delete mode 100644 modules/auth/js/login.js delete mode 100644 modules/auth/libraries/Auth.php delete mode 100644 modules/auth/libraries/drivers/Auth.php delete mode 100644 modules/auth/libraries/drivers/Auth/Basic.php delete mode 100644 modules/auth/models/password.php delete mode 100644 modules/auth/tests/Auth_Installer_Test.php delete mode 100644 modules/auth/views/login.html.php (limited to 'modules') diff --git a/modules/auth/config/auth.php b/modules/auth/config/auth.php deleted file mode 100644 index b63cc114..00000000 --- a/modules/auth/config/auth.php +++ /dev/null @@ -1,37 +0,0 @@ -where("name", "auth")->find()->version; - } catch (Exception $e) { - if ($e->getCode() == E_DATABASE_ERROR) { - $base_version = 0; - } else { - Kohana::log("error", $e); - throw $e; - } - } - Kohana::log("debug", "base_version: $base_version"); - - if ($base_version == 0) { - $db->query("CREATE TABLE IF NOT EXISTS `passwords` ( - `id` int(9) NOT NULL auto_increment, - `user_id` int(9) NOT NULL, - `password` varchar(1128) NOT NULL, - `logins` int(10) unsigned NOT NULL default '0', - `last_login` int(10) unsigned NOT NULL default '0', - PRIMARY KEY (`id`), - UNIQUE KEY (`user_id`)) - ENGINE=InnoDB DEFAULT CHARSET=utf8;"); - - $user_module = ORM::factory("module")->where("name", "auth")->find(); - $user_module->name = "auth"; - $user_module->version = 1; - $user_module->save(); - - $user = ORM::factory("user")->where("name", "admin")->find(); - Auth::instance()->set_user_password($user->id, "admin"); - } - } - - public static function uninstall() { - $db = Database::instance(); - $db->query("DROP TABLE IF EXISTS `passwords`;"); - ORM::factory("module")->where("name", "auth")->find()->delete(); - } -} \ No newline at end of file diff --git a/modules/auth/js/login.js b/modules/auth/js/login.js deleted file mode 100644 index db344d6f..00000000 --- a/modules/auth/js/login.js +++ /dev/null @@ -1,68 +0,0 @@ -//SETTING UP OUR POPUP -//0 means disabled; 1 means enabled; -var popupStatus = 0; - -//loading popup with jQuery magic! -function loadPopup(){ - //loads popup only if it is disabled - if(popupStatus==0){ - $("#backgroundPopup").css({"opacity": "0.7"}); - $("#backgroundPopup").fadeIn("slow"); - $("#gLoginPopup").fadeIn("slow"); - popupStatus = 1; - } -} - -//disabling popup with jQuery magic! -function disablePopup(){ - //disables popup only if it is enabled - if(popupStatus==1){ - $("#backgroundPopup").fadeOut("slow"); - $("#gLoginPopup").fadeOut("slow"); - popupStatus = 0; - } -} - -//centering popup -function centerPopup(){ - //request data for centering - var windowWidth = document.documentElement.clientWidth; - var windowHeight = document.documentElement.clientHeight; - var popupHeight = $("#gLoginPopup").height(); - var popupWidth = $("#gLoginPopup").width(); - //centering - $("#gLoginPopup").css({ - "position": "absolute", - "top": windowHeight/2-popupHeight/2, - "left": windowWidth/2-popupWidth/2 - }); - //only need force for IE6 - $("#backgroundPopup").css({"height": windowHeight}); -} - -$(document).ready(function(){ - //LOADING POPUP - //Click the button event! - $("#login").click(function(){ - //centering with css - centerPopup(); - //load popup - loadPopup(); - }); - //CLOSING POPUP - //Click the x event! - $("#gLoginPopupClose").click(function() { - disablePopup(); - }); - //Click out event! - $("#backgroundPopup").click(function() { - disablePopup(); - }); - //Press Escape event! - $(document).keypress(function(e) { - if(e.keyCode==27 && popupStatus==1) { - disablePopup(); - } - }); -}); - diff --git a/modules/auth/libraries/Auth.php b/modules/auth/libraries/Auth.php deleted file mode 100644 index c5afe92b..00000000 --- a/modules/auth/libraries/Auth.php +++ /dev/null @@ -1,88 +0,0 @@ -_driver = $driver; - $this->_config = $config; - - Kohana::log('debug', 'Auth Library initialized'); - } - - /** - * @see Auth_Driver::set_user_password - */ - public function set_user_password($user_id, $password) { - return $this->_driver->set_user_password($user_id, $password); - } - - /** - * @see Auth_Driver::is_valid_password - */ - public function is_valid_password($user_id, $password) { - return $this->_driver->is_valid_password($user_id, $password); - } -} diff --git a/modules/auth/libraries/drivers/Auth.php b/modules/auth/libraries/drivers/Auth.php deleted file mode 100644 index 6a6d31b6..00000000 --- a/modules/auth/libraries/drivers/Auth.php +++ /dev/null @@ -1,37 +0,0 @@ -_config = $config; - - Kohana::log('debug', 'Auth_Basic_Driver Library initialized'); - } - - /** - * @see Auth_Driver::set_user_password - * - * @param int $user_id - * @param string $password - * @return void - */ - public function set_user_password($user_id, $password_text) { - $password = ORM::factory("password")->where('user_id', $user_id)->find(); - $password->password = $this->_hash_password($password_text); - if (empty($password->user_id)) { - $password->user_id = $user_id; - } - $password->save(); - } - - /** - * Validates a user id password combination. - * - * @param int user_id - * @param string password - * @return boolean - */ - public function is_valid_password($user_id, $password_text) { - $password = ORM::factory("password") - ->where('user_id', $user_id) - ->find(); - if ($password->loaded != true) { - return false; - } - - // Get the salt from the stored password - $salt = $this->_find_salt($password->password); - $hashed = $this->_hash_password($password_text, $salt); - - return $hashed === $password->password; - } - - /** - * Creates a hashed password from a plaintext password, inserting salt - * based on the configured salt pattern. - * - * @param string plaintext password - * @return string hashed password string - */ - private function _hash_password($password, $salt = FALSE) { - if ($salt === FALSE) { - // Create a salt seed, same length as the number of offsets in the pattern - $salt = substr($this->_hash(uniqid(NULL, TRUE)), 0, count($this->_config['salt_pattern'])); - } - - // Password hash that the salt will be inserted into - $hash = $this->_hash($salt . $password); - - // Change salt to an array - $salt = str_split($salt, 1); - - // Returned password - $password = ''; - - // Used to calculate the length of splits - $last_offset = 0; - - foreach ($this->_config['salt_pattern'] as $offset) { - // Split a new part of the hash off - $part = substr($hash, 0, $offset - $last_offset); - - // Cut the current part out of the hash - $hash = substr($hash, $offset - $last_offset); - - // Add the part to the password, appending the salt character - $password .= $part . array_shift($salt); - - // Set the last offset to the current offset - $last_offset = $offset; - } - - // Return the password, with the remaining hash appended - return $password . $hash; - } - - /** - * Perform a hash, using the configured method. - * - * @param string string to hash - * @return string - */ - private function _hash($str) { - return hash($this->_config['hash_method'], $str); - } - - /** - * Finds the salt from a password, based on the configured salt pattern. - * - * @param string hashed password - * @return string - */ - private function _find_salt($password) { - $salt = ''; - - foreach ($this->_config['salt_pattern'] as $i => $offset) { - // Find salt characters... take a good long look.. - $salt .= substr($password, $offset + $i, 1); - } - - return $salt; - } -} - diff --git a/modules/auth/models/password.php b/modules/auth/models/password.php deleted file mode 100644 index fd1fee58..00000000 --- a/modules/auth/models/password.php +++ /dev/null @@ -1,22 +0,0 @@ -find(1); - - $auth = Auth::instance(array('driver' => 'Basic')); - - $auth->set_user_password($user->id, "test_password"); - - $this->assert_false($auth->is_valid_password($user->id, "invalid_password")); - $this->assert_true($auth->is_valid_password($user->id, "test_password")); - } -} diff --git a/modules/auth/views/login.html.php b/modules/auth/views/login.html.php deleted file mode 100644 index 417f3903..00000000 --- a/modules/auth/views/login.html.php +++ /dev/null @@ -1,26 +0,0 @@ - -
- - "> | - Login - - - - - " media="screen,print,projection" /> -
- x - -
- - "> - - - -
\ No newline at end of file diff --git a/modules/gallery_unit_test/controllers/test.php b/modules/gallery_unit_test/controllers/test.php index 6e00acb5..203edcba 100644 --- a/modules/gallery_unit_test/controllers/test.php +++ b/modules/gallery_unit_test/controllers/test.php @@ -62,7 +62,6 @@ class Test_Controller extends Controller { // this way. Uninstall modules first and core last. Ignore errors during uninstall. try { comment_installer::uninstall(); - auth_installer::uninstall(); user_installer::uninstall(); core_installer::uninstall(); } catch (Exception $e) { @@ -70,7 +69,6 @@ class Test_Controller extends Controller { core_installer::install(); user_installer::install(); - auth_installer::install(); comment_installer::install(); print new Unit_Test(); -- cgit v1.2.3