I've fixed this. Basically, it was a security context issue. In case someone 
runs into a similar problem, here is the problem and my solution.

A Twig_Error_Runtime exception was getting thrown due to there not being an 
authentication token set. This gets triggered when attempting to render my 
exception template (I've overridden 
FrameworkBundle\Resources\views\Exception\error.html.twig).

"An exception has been thrown during the rendering of a template ("The 
security context contains no authentication token. One possible reason may 
be that there is no firewall configured for this URL.") in 
"::layout.html.twig" at line 57."

I have the following in ::layout.html.twig:

{% if is_granted('ROLE_MEMBER') %}
    {% include '::menus.js.twig' %}
{% endif %}

I also have two other calls to isGranted() in two MenuBundle menu classes. I 
fixed this problem by adding the following check in my menu classes:

$security = $this->container->get('security.context');

if ($security->getToken() instanceof TokenInterface)
{
    $isGranted = $security->isGranted('SOME_ROLE');
}
else
{
    $isGranted = false;
}

To fix the issue with is_granted() in my template, I simply render an action 
instead and use the same check as above. So, definitely not a bug in the 
framework. It was just a seemingly unrelated issue with my code. :)

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en

Reply via email to