最近,我们得到了我们的Laravel 5.6应用渗透测试,其中被标记的问题之一是没有正确设置注销到期。该AuthenticatesUsers特质呼吁基本上刷新会话数据和再生的ID,但不设置过期它的会话的无效方法。
根据该报告,如果攻击者能够获得有效的会话令牌,他们将能够劫持受影响的用户的帐户。用户注销并不会使攻击者的会话。
任何指针在这里将有很大的帮助。
谢谢
/**
* Log the user out of the application.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function logout(Request $request)
{
$this->guard()->logout();
$request->session()->invalidate();
return redirect('/');
}
Laravel 5.6添加用于该目的的方法Auth::logoutOtherDevices()
:
https://laravel.com/docs/5.7/authentication#invalidating-sessions-on-other-devices https://laracasts.com/series/whats-new-in-laravel-5-6/episodes/7 https://github.com/laravel/framework/issues/16311