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
23 changes: 22 additions & 1 deletion components/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ protected function authenticateSession()
]);
}

if (Request::session()->get("password_hash_{$driver}") !== $user->getAuthPassword()) {
if (!$this->isValidSessionPasswordHash($user->getAuthPassword(), Request::session()->get("password_hash_{$driver}"))) {
$logoutFunc();
return;
}
Expand All @@ -386,4 +386,25 @@ protected function authenticateSession()
}
});
}

/**
* isValidSessionPasswordHash accepts the raw password hash stored by this component
* and the HMAC hash stored by SessionGuard::login() since Laravel 12.69.3
*
* @see \Illuminate\Session\Middleware\AuthenticateSession::validatePasswordHash
*/
protected function isValidSessionPasswordHash($passwordHash, $storedHash): bool
{
if (!is_string($passwordHash) || !is_string($storedHash)) {
return false;
}

if (hash_equals($passwordHash, $storedHash)) {
return true;
}

return method_exists(Auth::guard(), 'hashPasswordForCookie')
&& hash_equals(Auth::hashPasswordForCookie($passwordHash), $storedHash);
}

}
Loading