/usr/share/php/kohana2/modules/auth/libraries/drivers/Auth.php is in libkohana2-modules-php 2.3.4-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | <?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* Abstract Auth driver, must be extended by all drivers.
*
* $Id: Auth.php 4346 2009-05-11 17:08:15Z zombor $
*
* @package Auth
* @author Kohana Team
* @copyright (c) 2007-2008 Kohana Team
* @license http://kohanaphp.com/license.html
*/
abstract class Auth_Driver {
// Session instance
protected $session;
// Configuration
protected $config;
/**
* Creates a new driver instance, loading the session and storing config.
*
* @param array configuration
* @return void
*/
public function __construct(array $config)
{
// Load Session
$this->session = Session::instance();
// Store config
$this->config = $config;
}
/**
* Checks if a session is active.
*
* @param string role name (not supported)
* @return boolean
*/
public function logged_in($role)
{
return isset($_SESSION[$this->config['session_key']]);
}
/**
* Gets the currently logged in user from the session.
* Returns FALSE if no user is currently logged in.
*
* @return mixed
*/
public function get_user()
{
if ($this->logged_in(NULL))
{
return $_SESSION[$this->config['session_key']];
}
return FALSE;
}
/**
* Logs a user in.
*
* @param string username
* @param string password
* @param boolean enable auto-login
* @return boolean
*/
abstract public function login($username, $password, $remember);
/**
* Forces a user to be logged in, without specifying a password.
*
* @param mixed username
* @return boolean
*/
abstract public function force_login($username);
/**
* Logs a user in, based on stored credentials, typically cookies.
* Not supported by default.
*
* @return boolean
*/
public function auto_login()
{
return FALSE;
}
/**
* Log a user out.
*
* @param boolean completely destroy the session
* @return boolean
*/
public function logout($destroy)
{
if ($destroy === TRUE)
{
// Destroy the session completely
Session::instance()->destroy();
}
else
{
// Remove the user from the session
$this->session->delete($this->config['session_key']);
// Regenerate session_id
$this->session->regenerate();
}
// Double check
return ! $this->logged_in(NULL);
}
/**
* Get the stored password for a username.
*
* @param mixed username
* @return string
*/
abstract public function password($username);
/**
* Completes a login by assigning the user to the session key.
*
* @param string username
* @return TRUE
*/
protected function complete_login($user)
{
// Regenerate session_id
$this->session->regenerate();
// Store username in session
$_SESSION[$this->config['session_key']] = $user;
return TRUE;
}
} // End Auth_Driver
|