title: Upgrading Spring Boot 1.5 to 2 <sec:authorize> not working
body: <p>I've been upgrading my app to use spring boot 2 and my views have not been rendering correctly. They content that should be hidden with the  is no longer working. My methods and pages are still secured properly so it seems to be an issue with rendering the page. Also, isAuthenticated and isAnonymous don't work either.</p>
  
  <p>I've tried changing  to  and my security tag to xmlns:sec="http://www.thymeleaf.org/extras/spring-security" from xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4"</p>
  
  <p>SECURITY CONFIG</p>
  
  <pre><code>@Configuration
  @EnableWebSecurity
  @EnableGlobalMethodSecurity(prePostEnabled = true)
  public class SecurityConfig extends WebSecurityConfigurerAdapter {
  
  @Autowired
  private BCryptPasswordEncoder bCryptPasswordEncoder;
  
  @Autowired
  private DataSource dataSource;
  
  @Autowired
  private CustomAccessDenied accessDeniedHandler;
  
  @Value("${spring.queries.users-query}")
  private String usersQuery;
  
  @Value("${spring.queries.roles-query}")
  private String rolesQuery;
  
  @Override
  protected void configure(AuthenticationManagerBuilder auth) throws Exception {
      auth.jdbcAuthentication().usersByUsernameQuery(usersQuery).authoritiesByUsernameQuery(rolesQuery).dataSource(dataSource).passwordEncoder(bCryptPasswordEncoder);
  }
  
  @Override
  protected void configure(HttpSecurity http) throws Exception {
  
      http.csrf().disable()
              .authorizeRequests()
                  .antMatchers("/" , "/home").permitAll()
                  .antMatchers("/admin/**").hasAnyRole("ADMIN, OWNER")
                  .antMatchers("/register/**").hasAnyRole("ADMIN, CASHIER")
                  .antMatchers("/staff/**").authenticated()
                  .anyRequest().authenticated()
              .and()
              .formLogin()
                  .loginPage("/login")
                  .permitAll()
                  .and()
                  .logout()
                      .invalidateHttpSession(true)
                      .clearAuthentication(true)
                      .logoutRequestMatcher(new AntPathRequestMatcher("/logout"))
                      .logoutSuccessUrl("/")
                      .permitAll()
                  .and()
                  .headers()
                  .frameOptions().disable()
                  .and()
                  .exceptionHandling()
                      .accessDeniedHandler(accessDeniedHandler);
  }
  
  @Override
  public void configure(WebSecurity web) throws Exception {
      web.ignoring().antMatchers("/resources/**", "/static/**", "/css/**", "/js/**", "/pics/**", "/fonts/**");
  }
  }
  </code></pre>
  
  <p>HTML PAGE</p>
  
  <pre><code>    &lt;!DOCTYPE HTML&gt;
      &lt;html xmlns="http://www.w3.org/1999/xhtml" 
      xmlns:th="http://www.thymeleaf.org" 
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4"&gt;
      &lt;head&gt;
      &lt;title&gt;Home&lt;/title&gt;
      &lt;div th:replace="fragments/css"&gt;&lt;/div&gt;
  
      &lt;/head&gt;
      &lt;body&gt;
      &lt;div th:replace="fragments/header"&gt;&lt;/div&gt;
      &lt;main&gt;
      &lt;div class="scale-transition scale-out" sec:authorize="isAnonymous()"&gt;
          &lt;!-- USER NOT LOGGED IN MENU --&gt;
          &lt;div class="row" style="margin-top: 25px"&gt;
              &lt;div class="col s12 m8 offset-m2"&gt;
                  &lt;form id="idcards"&gt;
                              &lt;h1 class="center-align"&gt;SWIPE YOUR CARD TO LOGIN&lt;/h1&gt;
                 &lt;h4 class="center-align"&gt;TAP GREY BOX IF NOT WORKING&lt;/h4&gt;
                      &lt;input class="center-align grey lighten-3" style="height: 100px; font-size: 60px" id="cardData" type='password' value='' autofocus&gt;
                      &lt;input class="hide" type="button" value="Fill fields" id="filler2" onClick="fillValuesInTextBoxes()"&gt;
                  &lt;/form&gt;
              &lt;/div&gt;
              &lt;div class="row"&gt;
                  &lt;div class="col s12 m8 offset-m2" style="margin-top: 50px"&gt;
                      &lt;h3 class="center-align" style="text-decoration: underline;"&gt;ANNOUNCEMENTS&lt;/h3&gt;
                      &lt;div&gt;
                          &lt;div class="card-panel col s12 m4" th:each="announcementsList: ${announcementsList}"&gt;
                              &lt;p class="col s12 m10 offset-m1" th:text="${announcementsList.text}"&gt;&lt;/p&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;/main&gt;
      &lt;div th:replace="fragments/footer"&gt;&lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>DEPENDENCIES</p>
  
  <pre><code> &lt;parent&gt;
      &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
      &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
      &lt;version&gt;2.1.0.RELEASE&lt;/version&gt;
      &lt;relativePath /&gt; &lt;!-- lookup parent from repository --&gt;
  &lt;/parent&gt;
  
  &lt;properties&gt;
      &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
      &lt;project.reporting.outputEncoding&gt;UTF-8&lt;/project.reporting.outputEncoding&gt;
      &lt;java.version&gt;1.8&lt;/java.version&gt;
  &lt;/properties&gt;
  
  &lt;dependencies&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-data-jpa&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-security&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-thymeleaf&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-webflux&lt;/artifactId&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;mysql&lt;/groupId&gt;
          &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
          &lt;scope&gt;runtime&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;
          &lt;artifactId&gt;spring-security-test&lt;/artifactId&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.webflow&lt;/groupId&gt;
          &lt;artifactId&gt;spring-webflow&lt;/artifactId&gt;
          &lt;version&gt;2.4.4.RELEASE&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.google.guava&lt;/groupId&gt;
          &lt;artifactId&gt;guava&lt;/artifactId&gt;
          &lt;version&gt;27.0.1-jre&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
          &lt;artifactId&gt;hibernate-jpamodelgen&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.thymeleaf.extras&lt;/groupId&gt;
          &lt;artifactId&gt;thymeleaf-extras-springsecurity4&lt;/artifactId&gt;
          &lt;version&gt;3.0.4.RELEASE&lt;/version&gt;
      &lt;/dependency&gt;
  &lt;/dependencies&gt;
  
  &lt;build&gt;
      &lt;plugins&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
          &lt;/plugin&gt;
          &lt;plugin&gt;
              &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
              &lt;configuration&gt;
                  &lt;source&gt;1.6&lt;/source&gt;
                  &lt;target&gt;1.6&lt;/target&gt;
                  &lt;compilerArgument&gt;-proc:none&lt;/compilerArgument&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.bsc.maven&lt;/groupId&gt;
              &lt;artifactId&gt;maven-processor-plugin&lt;/artifactId&gt;
              &lt;executions&gt;
                  &lt;execution&gt;
                      &lt;id&gt;process&lt;/id&gt;
                      &lt;goals&gt;
                          &lt;goal&gt;process&lt;/goal&gt;
                      &lt;/goals&gt;
                      &lt;phase&gt;generate-sources&lt;/phase&gt;
                      &lt;configuration&gt;
                          &lt;!-- source output directory --&gt;
                          &lt;outputDirectory&gt;target/metamodel&lt;/outputDirectory&gt;
                      &lt;/configuration&gt;
                  &lt;/execution&gt;
              &lt;/executions&gt;
          &lt;/plugin&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
              &lt;artifactId&gt;build-helper-maven-plugin&lt;/artifactId&gt;
              &lt;executions&gt;
                  &lt;execution&gt;
                      &lt;id&gt;add-source&lt;/id&gt;
                      &lt;phase&gt;generate-sources&lt;/phase&gt;
                      &lt;goals&gt;
                          &lt;goal&gt;add-source&lt;/goal&gt;
                      &lt;/goals&gt;
                      &lt;configuration&gt;
                          &lt;sources&gt;
                              &lt;source&gt;target/metamodel&lt;/source&gt;
                          &lt;/sources&gt;
                      &lt;/configuration&gt;
                  &lt;/execution&gt;
              &lt;/executions&gt;
          &lt;/plugin&gt;
      &lt;/plugins&gt;
  &lt;/build&gt;
  </code></pre>