mirror of
https://github.com/billz/raspap-webgui.git
synced 2023-10-10 13:37:24 +02: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
@ -60,11 +60,7 @@ function safefilerewrite($fileName, $dataToSave)
|
|||||||
function ensureCSRFSessionToken()
|
function ensureCSRFSessionToken()
|
||||||
{
|
{
|
||||||
if (empty($_SESSION['csrf_token'])) {
|
if (empty($_SESSION['csrf_token'])) {
|
||||||
if (function_exists('mcrypt_create_iv')) {
|
$_SESSION['csrf_token'] = bin2hex(random_bytes(32));
|
||||||
$_SESSION['csrf_token'] = bin2hex(mcrypt_create_iv(32, MCRYPT_DEV_URANDOM));
|
|
||||||
} else {
|
|
||||||
$_SESSION['csrf_token'] = bin2hex(openssl_random_pseudo_bytes(32));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user