Implement a functional logout for spring-boot-keycloak

This commit is contained in:
Stefan de Konink 2021-04-01 21:28:29 +02:00
parent 53eedb7ad5
commit 37c6fe33d7
2 changed files with 9 additions and 0 deletions

View File

@ -8,6 +8,8 @@ import java.security.Principal;
import org.springframework.beans.factory.annotation.Autowired;
import javax.servlet.http.HttpServletRequest;
@Controller
public class WebController {
@ -19,6 +21,12 @@ public class WebController {
return "external";
}
@GetMapping("/logout")
public String logout(HttpServletRequest request) throws Exception {
request.logout();
return "redirect:/";
}
@GetMapping(path = "/customers")
public String customers(Principal principal, Model model) {
addCustomers();

View File

@ -27,6 +27,7 @@
</table>
<div id="pagefoot" th:include="layout :: footerFragment">Footer
</div>
<a href="/logout">Logout</a>
</div>
<!-- container -->
</body>