title: I logged success with spring security and redirect my home but is still anonymous
body: <p>My project is JSF with Spring security.</p>
  
  <p>I logged success with spring security and redirect my home, but is still anonymous. I user security tags and does not work.
    My class UserDetailsService:</p>
  
  <pre><code>public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
          UsuarioDetails usuario = userMapper.findByUsername(username);
  
       if (Objects.isNull(usuario)) throw new UsernameNotFoundException(username);
  
       return usuario;    
  }
  </code></pre>
  
  <p>and </p>
  
  <pre><code>protected void configure(HttpSecurity http) {
      try {
          List&lt;Transacao&gt; transacoes = transacaoDao.findAll();
  
              http.csrf().disable();
              http.authorizeRequests().antMatchers("/", "/index.xhtml", "/javax.faces.resource/**").permitAll();
  
                  http.authorizeRequests().anyRequest().authenticated()
                  .and()
                  .formLogin().loginPage("/template/login.xhtml").usernameParameter("username").passwordParameter("password")
                  .permitAll()
                  .failureUrl("/template/login.jsf?error=true").defaultSuccessUrl("/index.xhtml")
                  .and().exceptionHandling().accessDeniedPage("/403.xhtml")
                  .and().logout().logoutSuccessUrl("/login.xhtml").invalidateHttpSession(true).deleteCookies("JSESSIONID")
                  .and().httpBasic()
                  .and().sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS);;
  
              for(Transacao t : transacoes) {
                  http.authorizeRequests().antMatchers(t.getUrl()).access(t.getNome());
              }
          }
          catch (Exception ex) {
              throw new RuntimeException(ex);
          }
      }
  </code></pre>
  
  <p>My UserDetails have username, password and roles. When the login redirect to home page, in my controller i inpected:</p>
  
  <pre><code>Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
  </code></pre>
  
  <p>The Authentication is anonymusUser.
  And a user um my home page tags don't show elements:</p>
  
  <pre><code> &lt;sec:authorize access="hasRole('PROCESSO')"&gt;
      &lt;h:outputLabel value="Show my"&gt;&lt;/h:outputLabel&gt;
   &lt;/sec:authorize&gt;
  </code></pre>