KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am currently in the process of migrating a 2.0.* project to the current 2.1 beta of Symfony. In my functional tests i currently have this code to create a client with authentication: $client = // create a normal test client $role = 'ROLE_USER'; $firewallName = 'main'; $user = // pull a user from db $client->getCookieJar()->set(new \Symfony\Component\BrowserKit\Cookie(session_name(), true)); $token = new UsernamePasswordToken($user, null, $firewallName, array($role)); self::$kernel->getContainer()->get('session')->set('_security_' . $firewallName, serialize($token)); this works as expected in 2.0.* but not in 2.1, the data does not get set in the session. Any ideas? Edit (adding more info): it seems that the problem lies in the file " Symfony\Component\Security\Http\Firewall\ContextListener " in the method " onKernelResponse ". There is this code: if ((null === $token = $this->context->getToken()) || ($token instanceof AnonymousToken)) { $session->remove('_security_'.$this->contextKey); } else { $session->set('_security_'.$this->contextKey, serialize($token)); } in my case the if "$token instanceof AnonymousToken" is true, and because of that the session key gets removed. if i comment out that code everything works as expected. So i guess my new question is: What can i do to make the token not anonymous?
Tags (comma-separated)
Save Edits
Cancel