我正在尝试直接在我的symfony 3应用程序中授权用户,例如:
$token = new UsernamePasswordToken($user, $user->getPassword(), 'user_db_provider', $user->getRoles());
$userProvider = new EntityUserProvider($this->getDoctrine(), User::class);
$rememberMeService = new TokenBasedRememberMeServices([$userProvider],$this->getParameter('secret'),'user_db_provider', [
'path' => '/',
'name' => 'AUTH_TOKEN',
'domain' => null,
'secure' => false,
'httponly' => true,
'lifetime' => 1209600, // 14 days
'always_remember_me' => true,
'remember_me_parameter' => '_remember_me'
]);
$response = new Response();
$rememberMeService->loginSuccess($request, $response, $token);
$this->get('security.token_storage')->setToken($token);
$response->sendHeaders();
Symfony debug:security.DEBUG:检测到记住我的cookie。但是我一直收到错误:“security.DEBUG:记住 - 我的身份验证失败,cookie的哈希值无效”。怎么了?