mirror of
https://github.com/RaspAP/raspap-webgui.git
synced 2024-11-22 07:30:23 +00:00
mcrypt_create_iv is deprecated, openssl_random_pseudo_bytes
depends on openssl. php7 has the platform-independent `random_bytes` to generate "cryptographically secure" random data. use that for csrf token.
This commit is contained in:
parent
490cb14acd
commit
7898dc24c8
1 changed files with 1 additions and 5 deletions
|
@ -60,11 +60,7 @@ function safefilerewrite($fileName, $dataToSave)
|
|||
function ensureCSRFSessionToken()
|
||||
{
|
||||
if (empty($_SESSION['csrf_token'])) {
|
||||
if (function_exists('mcrypt_create_iv')) {
|
||||
$_SESSION['csrf_token'] = bin2hex(mcrypt_create_iv(32, MCRYPT_DEV_URANDOM));
|
||||
} else {
|
||||
$_SESSION['csrf_token'] = bin2hex(openssl_random_pseudo_bytes(32));
|
||||
}
|
||||
$_SESSION['csrf_token'] = bin2hex(random_bytes(32));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue