title: Keycloak 403 error with Spring Boot
body: <p>I try to integrate keycloak on my web app, which is using spring boot but i have an issue that I don't know exactly how to deal with.</p>
  
  <p>I have here the application.properties</p>
  
  <pre><code>keycloak.auth-server-url=http://localhost:8080/auth
  keycloak.realm=SpringBoot
  keycloak.resource=GCE
  keycloak.public-client=true
  keycloak.ssl-required=external
  
  keycloak.security-constraints[0].authRoles[0]=user
  keycloak.security-constraints[0].securityCollections[0].patterns[0]=/start
  
  server.port=8180
  spring.session.store-type=none
  </code></pre>
  
  <p>Here is my controller, and where I start the app</p>
  
  <pre><code>@SpringBootApplication
  public class GCEApplication {
  
  public static void main(String[] args) {
  
  SpringApplication.run(GCEFinalApplication.class, args);
  }
  }
  
  @Controller
  class AppController {
  
  @GetMapping(path = "/start")
  public String start(){
      System.out.println(1);
      return "start";
  }
  
  @GetMapping(path = "/logout")
  public String logout(HttpServletRequest request) {
      try {
          request.logout();
      } catch (Exception e) {
          System.out.println(e.getStackTrace());
      }
      HttpSession session = request.getSession(false);
      if (session != null) {
          session.invalidate();
      }
      return "/";
  }
  }
  </code></pre>
  
  <p>This is my index page, and it is in resources/static</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-springsecurity3"
  xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"&gt;
  &lt;head&gt;
  &lt;meta charset="ISO-8859-1"&gt;
  &lt;title&gt;Insert title here&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;a href="/start"&gt;Start&lt;/a&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>And the start page is .ftl template</p>
  
  <pre><code>&lt;#import "/spring.ftl" as spring&gt;
  &lt;html&gt;
  &lt;h1&gt;My products&lt;/h1&gt;
  
  &lt;br&gt;
  &lt;a href="/logout"&gt;Logout&lt;/a&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>When I try to access the start page it gave me 403 error. 
  It works to connect to Keycloak, and the session starts but I think the redirect is not ok</p>