Answer the question
In order to leave comments, you need to log in
How to encrypt a session in symfony?
Hello! I'm trying to use a proxy as per the documentation for a given task. But for some reason nothing happens. Perhaps I forgot to register something additionally somewhere? Has anyone encountered such a problem?
Proxy code (one to one with documentation):
namespace SecurityBundle\Session;
use Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy;
class EncryptedSessionProxy extends SessionHandlerProxy
{
private $key;
public function __construct( \SessionHandlerInterface $handler, $key)
{
$this->key = $key;
parent::__construct($handler);
}
public function read($id)
{
$data = parent::read($id);
return mcrypt_decrypt(\MCRYPT_3DES, $this->key, $data,'ecb');
}
public function write($id, $data)
{
$data = mcrypt_encrypt(\MCRYPT_3DES, $this->key, $data,'ecb');
return parent::write($id, $data);
}
}
security.encrypt_native_session:
class: SecurityBundle\Session\EncryptedSessionProxy
arguments: ['@session.handler.native_file','secret_string']
session:
handler_id: security.encrypt_native_session
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question