title: Thymeleaf spring security dialect doesn't work at all
body: <p>I want to use spring security dialect but when i use it's tags it doesn't work at all. It shows sec:authorize content anyways weather it is authenticated or not.</p>
  
  <p>here is pom:</p>
  
  <pre><code> &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;
              &lt;artifactId&gt;spring-security-core&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;
              &lt;artifactId&gt;spring-security-web&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;
              &lt;artifactId&gt;spring-security-config&lt;/artifactId&gt;
          &lt;/dependency&gt;
  &lt;dependency&gt;
              &lt;groupId&gt;org.thymeleaf&lt;/groupId&gt;
              &lt;artifactId&gt;thymeleaf-spring5&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;2.1.2.RELEASE&lt;/version&gt;
          &lt;/dependency&gt;
  </code></pre>
  
  <p>here is one of my pages:</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;meta charset="utf-8"/&gt;
      &lt;div th:replace="fragments/header :: header-css"&gt;&lt;/div&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;div th:replace="fragments/header :: header"/&gt;
  &lt;div class="container"&gt;
      &lt;header&gt;
          &lt;h1 align="center"&gt;
              Main Page
              &lt;div class="logout" sec:authorize="hasAnyAuthority('ADMIN')"&gt;
                          &lt;span id="currentUserLogin" sec:authentication="name" &gt;
                              user temp
                          &lt;/span&gt;
                  &lt;a href="/logout"&gt;
                      &lt;i class="icon-off"&gt;&lt;/i&gt;
                  &lt;/a&gt;
              &lt;/div&gt;
          &lt;/h1&gt;
      &lt;/header&gt;
  &lt;/div&gt;
  &lt;div th:replace="fragments/footer :: footer"/&gt;
  &lt;script src="/resources/jquery-1.8.1.min.js"&gt;&lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>it always shows logout  with 'user temp' text no matter what. Can anyone help me understand why is it happening?
  I'm using cairo-sr7 for dependacy mnagment</p>
  
  <pre><code>&lt;dependencyManagement&gt;
          &lt;dependencies&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;io.spring.platform&lt;/groupId&gt;
                  &lt;artifactId&gt;platform-bom&lt;/artifactId&gt;
                  &lt;version&gt;Cairo-SR7&lt;/version&gt;
                  &lt;type&gt;pom&lt;/type&gt;
                  &lt;scope&gt;import&lt;/scope&gt;
              &lt;/dependency&gt;
          &lt;/dependencies&gt;
      &lt;/dependencyManagement&gt;
  </code></pre>
  
  <p>i think i need to register dialect through template engine but how should i do it?
  here is my webMvcConfig</p>
  
  <pre><code>@Configuration
  @EnableWebMvc
  @ComponentScan(basePackages = {"com.rjproject"})
  public class WebMvcConfig implements WebMvcConfigurer {
  
      @Autowired
      private ApplicationContext applicationContext;
  
      @Bean
      public SpringResourceTemplateResolver templateResolver() {
          SpringResourceTemplateResolver templateResolver = new SpringResourceTemplateResolver();
          templateResolver.setApplicationContext(applicationContext);
          templateResolver.setPrefix("/WEB-INF/templates/");
          templateResolver.setSuffix(".html");
          templateResolver.setTemplateMode(TemplateMode.HTML);
          templateResolver.setCacheable(true);
          return templateResolver;
      }
  
      @Bean
      public SpringTemplateEngine templateEngine() {
          SpringTemplateEngine templateEngine = new SpringTemplateEngine();
          templateEngine.setTemplateResolver(templateResolver());
          templateEngine.setEnableSpringELCompiler(true);
          return templateEngine;
      }
  
      @Bean
      public ViewResolver viewResolver() {
          ThymeleafViewResolver viewResolver = new ThymeleafViewResolver();
          viewResolver.setTemplateEngine(templateEngine());
          return viewResolver;
      }
  
      @Override
      public void addResourceHandlers(final ResourceHandlerRegistry registry) {
          registry.addResourceHandler("/resources/**").addResourceLocations("/resources/");
      }
  }
  </code></pre>