title: my website /home for authenticated users and anonymous
body: <p>I don't understand my problem. I just want :</p>
  
  <ul>
  <li><p>/ redirected /home</p></li>
  <li><p>/home is not secured but logged user is able to navigate into
  the whole website.</p></li>
  <li><p>Non authenticated user is only able to see the homepage</p></li>
  <li><p>People can register an account to access the whole website</p></li>
  </ul>
  
  <p>So it's my security.yml config :</p>
  
  <pre><code>security:
      encoders:
          Siriru\AntBundle\Entity\User: sha512
  
      role_hierarchy:
          ROLE_ADMIN:       ROLE_USER
          ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]
  
      providers:
          main:
              entity: { class: Siriru\AntBundle\Entity\User, property: username }
  
      firewalls:
          dev:
              pattern:  ^/(_(profiler|wdt)|css|images|js)/
              security: false
  
          root:
              pattern: ^/$
              security: false
  
          home:
              pattern: ^/home$
              security: false
  
          login:
              pattern:  ^/login$
              security: false
  
          register:
              pattern: ^/account/
              security: false
  
          secured_area:
              pattern:    ^/
              form_login:
                  check_path: /login_check
                  login_path: /login
                  username_parameter: username
                  password_parameter: password
  
              logout:
                  path:   /logout
                  target: /home
  </code></pre>
  
  <p>Registration is ok, login too. But after the redirection to the homepage, user is not authenticated (in the symfony profiler "You are not authenticated."). If I reach the secured area, i'm logged but not authenticated.</p>
  
  <pre><code>&lt;?php
  
  namespace Siriru\AntBundle\Controller;
  
  use Siriru\AntBundle\Form\Model\Registration;
  use Siriru\AntBundle\Form\Type\RegistrationType;
  
  use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  use Symfony\Component\Security\Core\SecurityContext;
  use Symfony\Component\HttpFoundation\Response;
  use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
  use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
  use JMS\SecurityExtraBundle\Annotation\Secure;
  
  class AccountController extends Controller
  {
      /**
       * @Route("/login", name="login")
       * @Template()
       */
      public function loginAction()
      {
          if ($this-&gt;get('request')-&gt;attributes-&gt;has(SecurityContext::AUTHENTICATION_ERROR)) {
              $error = $this-&gt;get('request')-&gt;attributes-&gt;get(SecurityContext::AUTHENTICATION_ERROR);
          } else {
              $error = $this-&gt;get('request')-&gt;getSession()-&gt;get(SecurityContext::AUTHENTICATION_ERROR);
          }
  
          return array(
              'last_username' =&gt; $this-&gt;get('request')-&gt;getSession()-&gt;get(SecurityContext::LAST_USERNAME),
              'error'         =&gt; $error,
          );
      }
  
      /**
       * @Route("/login_check", name="login_check")
       */
      public function securityCheckAction()
      {
          // The security layer will intercept this request
      }
  
      /**
       * @Route("/logout", name="logout")
       */
      public function logoutAction()
      {
          // The security layer will intercept this request
      }
  
      /**
       * @Route("/account/register", name="account_register")
       * @Template()
       */
      public function registerAction()
      {
          $form = $this-&gt;createForm(new RegistrationType(), new Registration());
  
          return array('form' =&gt; $form-&gt;createView());
      }
  
      /**
       * @Route("/account/create", name="account_create")
       * @Template()
       */
      public function createAction()
      {
          $em = $this-&gt;getDoctrine()-&gt;getEntityManager();
  
          $form = $this-&gt;createForm(new RegistrationType(), new Registration());
  
          $form-&gt;bind($this-&gt;getRequest());
  
          if ($form-&gt;isValid()) {
              $registration = $form-&gt;getData();
              $user = $registration-&gt;getUser();
  
              $factory = $this-&gt;get('security.encoder_factory');
  
              $encoder = $factory-&gt;getEncoder($user);
              $password = $encoder-&gt;encodePassword($user-&gt;getPassword(), $user-&gt;getSalt());
              $user-&gt;setPassword($password);
              $em-&gt;persist($user);
              $em-&gt;flush();
  
              return $this-&gt;redirect($this-&gt;generateUrl('homepage'));
          }
  
          return $this-&gt;render('SiriruAntBundle:Account:register.html.twig', array('form' =&gt; $form-&gt;createView()));
      }
  }
  </code></pre>
  
  <p>I need some help =) Thank you.</p>