2013-05-27 63 views
-1

我在我的网站上使用ESI缓存;工作正常,今天我清除了APC缓存和sf2缓存,我看到一切正常。但有些人看不到esi面板等。Symfony2 ESI bug浏览器缓存

这是为什么,以及如何解决它?我不明白为什么我和一些朋友能看到它,而其他人不能?

Using symfony 2.1.7 

渲染这样:

$response=new Response(); 
$response= $this->render('HomePageBundle:Default:index.html.twig', array(... 
$response->setPrivate(true); 
$response->setMaxAge(300); 

return $response; 

我的网站/ app.php文件

require_once __DIR__.'/../app/bootstrap.php.cache'; 
require_once __DIR__.'/../app/AppKernel.php'; 
require_once __DIR__.'/../app/AppCache.php'; 

$loader = new ApcClassLoader('tb_sf2', $loader); 
$loader->register(true); 

$kernel = new AppKernel('prod', false); 
$kernel->loadClassCache(); 

// wrap the default AppKernel with the AppCache one 
$kernel = new AppCache($kernel); 

$request = Request::createFromGlobals(); 
$response = $kernel->handle($request); 
$response->send(); 
$kernel->terminate($request, $response); 

但是,如果这将是一个错误,我不会看到ESI板也一样,对不对?

我清除再次缓存一段时间(也许以后30分钟),一个说:

现在我可以看到左边的菜单,但上方,仍然什么也没有

我清除日志比我的朋友发...刷新每个ESI面板加入此日志:

[2013-05-27 23:03:17] request.INFO: Matched route "home_page_homepage" (parameters: "_controller": "TB\HomePageBundle\Controller\DefaultController::indexAction", "_route": "home_page_homepage") [] [] 
[2013-05-27 23:03:17] app.INFO: Locale Query Guessing Service Loaded [] [] 
[2013-05-27 23:03:17] app.INFO: Locale has not been identified by the Query guessing service [] [] 
[2013-05-27 23:03:17] app.INFO: Locale Session Guessing Service Loaded [] [] 
[2013-05-27 23:03:17] app.INFO: Locale has been identified by guessing service: (Session) [] [] 
[2013-05-27 23:03:17] app.INFO: Setting [ en ] as defaultLocale for the Request [] [] 
[2013-05-27 23:03:17] security.DEBUG: Read SecurityContext from the session [] [] 
[2013-05-27 23:03:17] security.DEBUG: Reloading user from user provider. [] [] 
[2013-05-27 23:03:17] security.DEBUG: Username "MbrunoM" was reloaded from user provider. [] [] 
[2013-05-27 23:03:18] security.DEBUG: Write SecurityContext in the session [] [] 
[2013-05-27 23:03:18] request.INFO: Matched route "notifications_box_esi" (parameters: "_controller": "TB\HomePageBundle\Controller\DefaultController::notificationsBoxEsiAction", "max": "10", "_route": "notifications_box_esi") [] [] 
[2013-05-27 23:03:18] app.INFO: Locale Query Guessing Service Loaded [] [] 
[2013-05-27 23:03:18] app.INFO: Locale has not been identified by the Query guessing service [] [] 

[2013-05-27 23:03:18] app.INFO: Locale Query Guessing Service Loaded [] [] 
[2013-05-27 23:03:18] app.INFO: Locale has not been identified by the Query guessing service [] [] 
[2013-05-27 23:03:18] app.INFO: Locale Session Guessing Service Loaded [] [] 
[2013-05-27 23:03:18] app.INFO: Locale has been identified by guessing service: (Session) [] [] 
[2013-05-27 23:03:18] app.INFO: Setting [ en ] as defaultLocale for the Request [] [] 
[2013-05-27 23:03:18] security.DEBUG: Read SecurityContext from the session [] [] 
[2013-05-27 23:03:18] security.DEBUG: Reloading user from user provider. [] [] 
[2013-05-27 23:03:18] security.DEBUG: Username "MbrunoM" was reloaded from user provider. [] [] 
[2013-05-27 23:03:18] security.DEBUG: Access is denied (and user is neither anonymous, nor remember-me) by "/var/www/domain.com/framework/vendor/symfony/symfony/src/Symfony/Component/Security/Http/Firewall/AccessListener.php" at line 70 [] [] 
[2013-05-27 23:03:18] security.DEBUG: Access is denied (and user is neither anonymous, nor remember-me) by "/var/www/domain.com/framework/vendor/symfony/symfony/src/Symfony/Component/Security/Http/Firewall/AccessListener.php" at line 70 [] [] 
+0

提供更多信息,渲染方法,配置..这symfony的版本?哪个反向代理?漆?内部?日志文件说什么? – nifr

+0

更新请检查 – EnchanterIO

+0

是啊..我结束了它在一堆文本,希望没有人通知之前,我编辑它..如果你想请改变你的评论从“吨.....”到“域”:D – EnchanterIO

回答

0

确保您的用户允许通过您的防火墙访问ESI路由。

防火墙配置中可能存在错误。您的用户无权访问路由'* notifications_box_esi *'。在您的调试日志有趣的线是这个:

security.DEBUG: Access is denied (and user is neither anonymous, nor remember-me) by "/var/www/nonamepage/framework/vendor/symfony/symfony/src/Symfony/Component/Security/Http/Firewall/AccessListener.php" at line 70 [] [] [2013-05-27 23:03:18] security. 

您的防火墙允许或限制访问某些航线/基于角色或访问决策管理器的URL。

的配置可以在security.yml发现:

security: 

    # ... 

    access_control: 
     - { path: ^/admin/users, roles: ROLE_SUPER_ADMIN } 
     - { path: ^/admin, roles: ROLE_ADMIN } 

    # ... or with an access decision manager 
    firewalls: 
     your_firewall_name: 
      pattern: ^/ 
      # ... 

您可以查看当前用户具有哪些角色有:

$this->get('security.context')->getToken()->getUser()->getRoles(); 
+0

是的,我注意到了,但怎么办呢?如何“盛大”访问此路线? – EnchanterIO

+0

搜索路线。安全检查可以通过is_granted()在树枝中或在控制器操作中渲染路由来实现。可能使用JMSSecurityExtraBundle注释......不知道项目的结构。 – nifr

+0

你已经意识到这个防火墙确定我知道他们... aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa omg ...有人打我请...好吧...解决方案出现在我脑海中后,我看到: - {path:^/admin/users ,角色:ROLE_SUPER_ADMIN} - {path:^/admin,roles:ROLE_ADMIN} this lines ...我一周前修改过的两行代码的图像出现在我的头上...并且我没有清除缓存,这就是为什么我coul不记得哪里的错误可能是...我有ROLE_SUPER_ADMIN为/ esi /和我是超级管理员,这就是为什么我看到一切都很好,我的朋友以及...啊啊 – EnchanterIO

0

我知道它是从2年前的一个问题但我有同样的问题: security.DEBUG:访问被拒绝(并且用户既不是匿名的,也不记得我)

问题是,如果我做的是grante d在我的LoginSuccessHandler中重定向到我的页面,我得到了良好的角色(ROLE_USER),但它仍然不起作用。 我已经清理了缓存,它没有任何区别。 如果我去symfony调试工具栏,它说:验证?没有(可能是因为用户没有角色)

这是我的安全。阳明海运和我LoginSuccessHandler:

security: 
 
    encoders: 
 
    Mainbundle\Entity\Personne: 
 
     algorithm:  sha512 
 
     encode_as_base64: false 
 
     iterations:  1 
 

 
    role_hierarchy: 
 
    ROLE_ADMIN:  ROLE_USER 
 
    ROLE_SUPER_ADMIN: [ ROLE_USER, ROLE_ADMIN, ROLE_MANAGER, ROLE_ALLOWED_TO_SWITCH ] 
 

 
    providers: 
 
    administrators: 
 
     entity: { class: MainBundle:Personne } 
 

 
    firewalls: 
 
    #wsse_secured: 
 
     #pattern: ^/api/.* 
 
     #stateless: true 
 
     #wsse: true 
 
    default: 
 
     #pattern:  ^/ 
 
     pattern:  ^/wsse 
 
     anonymous: ~ 
 
     #wsse:   true 
 
     form_login: 
 
     post_only:   true 
 
     use_forward:   false 
 
     provider:   administrators 
 
     csrf_provider:  form.csrf_provider 
 
     csrf_parameter:  _csrf_token 
 
     remember_me:   true 
 
     login_path:   login_route 
 
     check_path:   login_check 
 
     default_target_path: admin 
 
     failure_path:  null 
 
     success_handler:  main.component.authentication.handler.login_success_handler 
 
     logout: 
 
     path: \t \t \t \t  logout 
 
     target: \t \t \t /
 
     success_handler: main.component.authentication.handler.logout_success_handler 
 

 
    access_control: 
 
    - { path: ^/wsse/admin, roles: ROLE_USER } 
 
    - { path: ^/wsse, roles: IS_AUTHENTICATED_ANONYMOUSLY } 
 
    - { path: ^/api, roles: IS_AUTHENTICATED_FULLY } 
 
    #- { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY } 
 
    #- { path: ^/login_check, roles: IS_AUTHENTICATED_ANONYMOUSLY } 
 

 
    #providers: 
 
     #webservice: 
 
      #id: webservice_user_provider 
 
     #in_memory: 
 
      #memory: ~ 
 

 
    #encoders: 
 
     #MainBundle\Security\User\WebserviceUser: sha512

<?php 
 
    
 
namespace MainBundle\Component\Authentication\Handler; 
 
    
 
use Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface; 
 
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; 
 
use Symfony\Component\Security\Core\SecurityContext; 
 
use Symfony\Component\HttpFoundation\Request; 
 
use Symfony\Component\HttpFoundation\RedirectResponse; 
 
use Symfony\Component\Routing\Router; 
 
use Doctrine\ORM\EntityRepository; 
 
use MainBundle\Entity\UserRepository; 
 
use Symfony\Bundle\FrameworkBundle\Controller\Controller; 
 
use Mainbundle\Manager\UserManager; 
 

 
class LoginSuccessHandler extends Controller implements AuthenticationSuccessHandlerInterface 
 
{ 
 
\t protected $router; 
 
\t protected $security; 
 
\t protected $usermanager; 
 
\t 
 
\t public function __construct($usermanager, Router $router, SecurityContext $security) 
 
\t { 
 
\t \t $this->router = $router; 
 
\t \t $this->security = $security; 
 
\t \t $this->usermanager = $usermanager; 
 
\t } 
 
\t 
 
\t public function onAuthenticationSuccess(Request $request, TokenInterface $token) 
 
\t { 
 
\t \t $personne = $token->getUser(); 
 
\t \t $usermanager = $this->usermanager->getRepository(); 
 
\t \t $role_array = $this->usermanager->findRole($personne->getId()); 
 
\t \t $personne->setRoles($role_array); 
 
\t \t 
 
\t \t var_dump($this->security->getToken()->getUser()->getRoles()); 
 
\t \t 
 
\t \t if ($this->security->isGranted('ROLE_SUPER_ADMIN')) 
 
\t \t { 
 
\t \t \t $response = new RedirectResponse($this->router->generate('category_index')); 
 
\t \t } 
 
\t \t elseif ($this->security->isGranted('ROLE_ADMIN')) 
 
\t \t { 
 
\t \t \t $response = new RedirectResponse($this->router->generate('category_index')); 
 
\t \t } 
 
\t \t elseif ($this->security->isGranted('ROLE_USER')) 
 
\t \t { 
 
\t \t \t $response = new RedirectResponse($this->router->generate('admin')); 
 
\t \t \t // redirect the user to where they were before the login process begun. 
 
\t \t \t /*$referer_url = $request->headers->get('referer'); 
 
\t \t \t \t \t \t 
 
\t \t \t $response = new RedirectResponse($referer_url);*/ 
 
\t \t } 
 
\t \t elseif ($this->security->isGranted('ROLE_MANAGER')) 
 
\t \t { 
 
\t \t \t $response = new RedirectResponse($this->router->generate('admin')); 
 
\t \t } 
 
\t \t return $response; 
 
\t } \t 
 
}