sgrodzicki / hack-session-bundle
该包最新版本(dev-master)没有提供许可证信息。
hack技巧,允许在登录检查时启动会话
dev-master
2013-02-07 15:30 UTC
This package is not auto-updated.
Last update: 2024-09-14 12:34:28 UTC
README
目的
因为对于客户项目,我们在每个页面上都有一个登录表单,并且流量很高,我们希望会话启动得非常晚。目标是充分利用Varnish的优势,在VCL配置级别上关注缓存策略非常低,而在HTTP经典级别上更高。
当前问题指向这个问题: symfony/symfony#3703
假设
这个假设用于这个临时修复非常精确,但只允许一个'login_check'路由(所以对于一个防火墙)
开始
首先,必须像这样禁用auto_start会话参数
# app/config/config.yml
...
framework:
...
session:
auto_start: false
安装
将该包添加到您项目的deps文件中
# deps
[HackSessionBundle]
git=git@github.com:gillest/HackSessionBundle.git
target=bundles/Gilles/Bundle/HackSessionBundle
然后运行包安装命令
./bin/vendors install
将包命名空间添加到自动加载配置文件中。
# app/autoload.php
<?php
...
$loader->registerNamespaces(array(
...
'Gilles' => __DIR__.'/../vendor/bundles',
));
然后,在kernel中注册该包
# app/AppKernel.php
<?php
...
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
...
new Gilles\Bundle\HackSessionBundle\GillesHackSessionBundle(),
);
...
}
...
}
在配置级别,您需要向防火墙和hack监听器提供相同的参数
# app/config/config.yml
gilles_hack_session:
login_check_path: %local_form_login_check_path%
然后,将检查路径设置为为想要的防火墙区域设置的相同参数
# app/config/security.yml
security:
...
firewalls:
...
secured_area:
pattern: ^/demo/secured/
form_login:
check_path: %local_form_login_check_path%
现在,您可以设置登录检查的URL
# app/config/config.yml
parameters:
local_form_login_check_path: /demo/secured/login_check
结果
当URL设置为%local_form_login_check_path%时,会话现在不需要存在。