Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions plugins/authentication/cookie/cookie.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ public function onUserAuthenticate($credentials, $options, &$response)
if (!JUserHelper::verifyPassword($cookieArray[0], $results[0]->token))
{
/*
* This is a real attack! Either the series was guessed correctly or a cookie was stolen and used twice (once by attacker and once by victim).
* This is a real attack!
* Either the series was guessed correctly or a cookie was stolen and used twice (once by attacker and once by victim).
* Delete all tokens for this user!
*/
$query = $this->db->getQuery(true)
Expand Down Expand Up @@ -294,8 +295,8 @@ public function onUserAfterLogin($options)
}

// Get the parameter values
$lifetime = $this->params->get('cookie_lifetime', '60') * 24 * 60 * 60;
$length = $this->params->get('key_length', '16');
$lifetime = $this->params->get('cookie_lifetime', 60) * 24 * 60 * 60;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The value will be a string if not fallback so it would be better to convert with (int).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will be an integer because the field in manifest file has integer filter applied.

$length = $this->params->get('key_length', 16);

// Generate new cookie
$token = JUserHelper::genRandomPassword($length);
Expand Down Expand Up @@ -334,9 +335,9 @@ public function onUserAfterLogin($options)
->where($this->db->quoteName('uastring') . ' = ' . $this->db->quote($cookieName));
}

$hashed_token = JUserHelper::hashPassword($token);
$hashedToken = JUserHelper::hashPassword($token);

$query->set($this->db->quoteName('token') . ' = ' . $this->db->quote($hashed_token));
$query->set($this->db->quoteName('token') . ' = ' . $this->db->quote($hashedToken));

try
{
Expand Down