我正在尝试对会话数据进行加密 根据官方指示,但它不起作用。有人可以告诉我我做错了吗?
我的EncryptedSessionProxy
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);
}
}
我的service.yml
security.encrypt_native_session:
class: SecurityBundle\Session\EncryptedSessionProxy
arguments: ['@session.handler.native_file','secret_string']
我的config.yml
session:
handler_id: security.encrypt_native_session