Kohana v3.3.2
This commit is contained in:
@@ -48,7 +48,17 @@ class Kohana_Security {
|
||||
if ($new === TRUE OR ! $token)
|
||||
{
|
||||
// Generate a new unique token
|
||||
$token = sha1(uniqid(NULL, TRUE));
|
||||
if (function_exists('openssl_random_pseudo_bytes'))
|
||||
{
|
||||
// Generate a random pseudo bytes token if openssl_random_pseudo_bytes is available
|
||||
// This is more secure than uniqid, because uniqid relies on microtime, which is predictable
|
||||
$token = base64_encode(openssl_random_pseudo_bytes(32));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Otherwise, fall back to a hashed uniqid
|
||||
$token = sha1(uniqid(NULL, TRUE));
|
||||
}
|
||||
|
||||
// Store the new token
|
||||
$session->set(Security::$token_name, $token);
|
||||
@@ -100,4 +110,4 @@ class Kohana_Security {
|
||||
return str_replace(array('<?', '?>'), array('<?', '?>'), $str);
|
||||
}
|
||||
|
||||
} // End security
|
||||
}
|
||||
|
Reference in New Issue
Block a user