/** * @param string|null $cookieVal * @return bool */ public function parseAuthCookie($cookieVal = null) { if ($cookieVal === null) { $cookieName = $this->getAuthCookieName(); $cookieVal = !empty($_COOKIE[$cookieName]) && is_string($_COOKIE[$cookieName]) ? $_COOKIE[$cookieName] : ''; } $pieces = explode('|', $cookieVal); if (count($pieces) !== 3) { return false; } list($userID, $role, $signature) = $pieces; if (wfWAFUtils::hash_equals($signature, $this->getAuthCookieValue($userID, $role))) { return array('userID' => $userID, 'role' => $role); } return false; }
/** * @param string $nonce * @param string $action * @return bool */ public function verifyNonce($nonce, $action) { if (empty($nonce)) { return false; } return wfWAFUtils::hash_equals($nonce, $this->createNonce($action)); }