Kotlin – Spring Security Customize Logout Success Handler
In the tutorial, we will show you how to customize Logout Success Handler with Kotlin Spring Security web application.
I. Technologies
– Kotlin 1.2.20
– Apache Maven 3.5.2
– Spring Tool Suite – Version 3.9.0.RELEASE
– Spring Boot – 1.5.10.RELEASE
– Bootstrap
II. Goal
We create a Kotlin MVC Web Application as below:
We use LogoutSuccessHandler
to customize a behaviour of Kotlin Spring Security after logout successfully. In the tutorial, it will redirect to logoutsuccessful.html
page:
III. Implementation
1. Create Kotlin Spring Security web application
-> Follow the article: Kotlin SpringBoot – Configure Spring Security
2. Customize LogoutSuccessHandler
2.1. Create logoutsuccessful.html page
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:th="http://www.thymeleaf.org"
xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3">
<head>
<title>Welcome Security with Spring Boot!</title>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<link rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"/>
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script
src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body class="container" style="margin:50px">
<div class="row col-sm-5"
style="border: 1px ridge #003312; padding:20px; float: none; margin: 0 auto;">
<h1>Logout Successfully!</h1>
<a style="color: blue" th:href="@{/}">Home Page</a>
<br />
<a style="color: blue" th:href="@{/login}">Login Page</a>
</div>
</body>
</html>
2.2 Customize LogoutSuccessHandler
More at:
Kotlin – Spring Security Customize Logout Success Handler
Top comments (0)