title: Both isAnonymous() and isAuthenticated() are returning false
body: <p>I have a simple  page which is displays simple text depending on whether the user is logged in or not.</p>
  
  <pre><code>&lt;sec:authorize access="isAnonymous()"&gt;
      No, you failed!
  &lt;/sec:authorize&gt;
  &lt;sec:authorize access="isAuthenticated()"&gt;
     yes, logged in. Well done!
  &lt;/sec:authorize&gt;
  </code></pre>
  
  <p>The above code displays nothing! which means both isAuthenticated() and isAnonymous() have returned false. </p>
  
  <p>It is suggested here (<a href="https://stackoverflow.com/q/11999656/825957">Both isAnonymous() and isAuthenticated() return false on error page</a>) that I must use this configuration for my filter mapping:</p>
  
  <pre><code>&lt;filter-mapping&gt;
      &lt;filter-name&gt;springSecurityFilterChain&lt;/filter-name&gt;
      &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
      &lt;dispatcher&gt;REQUEST&lt;/dispatcher&gt;
      &lt;!-- apply Spring Security authentication to error-pages --&gt;
      &lt;dispatcher&gt;ERROR&lt;/dispatcher&gt;
  &lt;/filter-mapping&gt;
  </code></pre>
  
  <p>I am not using XML, but my configuration is the same:</p>
  
  <pre><code>EnumSet&lt;DispatcherType&gt; dispatcherTypes = EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD);
  characterEncoding.addMappingForUrlPatterns(dispatcherTypes, true, "/*");
  
  FilterRegistration.Dynamic security = servletContext.addFilter("springSecurityFilterChain", new DelegatingFilterProxy());
  security.addMappingForUrlPatterns(dispatcherTypes, true, "/*");
  </code></pre>
  
  <p>Why else would this happen?</p>
  
  <p>Edit:
  This is my security context:</p>
  
  <pre><code>@Configuration
  @EnableWebSecurity
  public class SecurityContext extends WebSecurityConfigurerAdapter {
  
  @Autowired
  private UserRepository userRepository;
  
  @Override
  public void configure(WebSecurity web) throws Exception {
      web
              //Spring Security ignores request to static resources such as CSS or JS files.
              .ignoring()
                  .antMatchers("/static/**");
  }
  
  @Override
  protected void configure(HttpSecurity http) throws Exception {
      http
              //Configures form login
              .formLogin()
                  .loginPage("/login")
                  .loginProcessingUrl("/login/authenticate")
                  .failureUrl("/login?error=bad_credentials")
              //Configures the logout function
              .and()
                  .logout()
                      .deleteCookies("JSESSIONID")
                      .logoutUrl("/logout")
                      .logoutSuccessUrl("/login")
              //Configures url based authorization
              .and()
                  .authorizeRequests()
                      //Anyone can access the urls
                      .antMatchers(
                              "/auth/**",
                              "/login",
                              "/signin/**",
                              "/signup/**",
                              "/user/register/**"
                      ).permitAll()
                      //The rest of the our application is protected.
                      .antMatchers("/**").hasRole("USER")
              //Adds the SocialAuthenticationFilter to Spring Security's filter chain.
              .and()
                  .apply(new SpringSocialConfigurer());
  }
  
  /**
  * Configures the authentication manager bean which processes authentication
  * requests.
  */
  @Override
  protected void configure(AuthenticationManagerBuilder auth) throws Exception {
      auth
              .userDetailsService(userDetailsService())
              .passwordEncoder(passwordEncoder());
  }
  
  /**
  * This is used to hash the password of the user.
  */
  @Bean
  public PasswordEncoder passwordEncoder() {
      return new BCryptPasswordEncoder(10);
  }
  
  /**
  * This bean is used to load the user specific data when social sign in
  * is used.
   */
  @Bean
  public SocialUserDetailsService socialUserDetailsService() {
      return new SimpleSocialUserDetailsService(userDetailsService());
  }
  
  /**
  * This bean is load the user specific data when form login is used.
  */
  @Bean
  public UserDetailsService userDetailsService() {
      return new RepositoryUserDetailsService(userRepository);
   }
  }  
  </code></pre>
  
  <p>This the page controller:</p>
  
  <pre><code>@Controller
  public class LoginController {
  
  private static final Logger LOGGER = LoggerFactory.getLogger(LoginController.class);
  
  protected static final String VIEW_NAME_LOGIN_PAGE = "user/login";
  
  @RequestMapping(value = "/login", method = RequestMethod.GET)
  public String showLoginPage() {
      LOGGER.debug("Rendering login page.");
      return VIEW_NAME_LOGIN_PAGE;
   }
  }
  </code></pre>