Kotlin – Spring Security Customize Logout Success Handler
Kotlin
104
springsecurity
5
logout
1
Male avatar

loveprogramming viết ngày 21/05/2021

https://grokonez.com/spring-framework/spring-boot/kotlin-spring-boot/kotlin-spring-security-customize-logout-success-handler

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:

Kotlin Spring Security - Customize LogOut Successfully - project structure

We use LogoutSuccessHandler to customize a behaviour of Kotlin Spring Security after logout successfully. In the tutorial, it will redirect to logoutsuccessful.html page:

Kotlin Spring Security - Customize LogOut Successfully - logout succesfully

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:

https://grokonez.com/spring-framework/spring-boot/kotlin-spring-boot/kotlin-spring-security-customize-logout-success-handler

Kotlin – Spring Security Customize Logout Success Handler

Bình luận


White
{{ comment.user.name }}
Bỏ hay Hay
{{comment.like_count}}
Male avatar
{{ comment_error }}
Hủy
   

Hiển thị thử

Chỉnh sửa

Male avatar

loveprogramming

545 bài viết.
97 người follow
Kipalog
{{userFollowed ? 'Following' : 'Follow'}}
Cùng một tác giả
Male avatar
1 0
Tutorial Link: (Link) (Ảnh) Django is a Pythonbased free and opensource web framework that follows the modeltemplateview architectural pattern. A...
loveprogramming viết 11 tháng trước
1 0
Male avatar
1 0
https://loizenai.com/angular11nodejspostgresqlcrudexample/ Angular 11 Node.js PostgreSQL Crud Example (Ảnh) Tutorial: “Angular 11 Node.js Postg...
loveprogramming viết 10 tháng trước
1 0
Male avatar
1 0
Angular Spring Boot jwt Authentication Example Github https://loizenai.com/angularspringbootjwt/ (Ảnh) Tutorial: ” Angular Spring Boot jwt Authe...
loveprogramming viết 10 tháng trước
1 0
Bài viết liên quan
Male avatar
0 0
https://grokonez.com/springframework/springsecurity/springsecurityjwtauthenticationrestapisspringbootspringmvcspringsecurityspringjpamysql Spring ...
loveprogramming viết 5 tháng trước
0 0
Male avatar
0 0
https://grokonez.com/springframework/springboot/kotlinspringboot/kotlinspringsecurityjdbcauthenticationspringbootmysqlbootstrap Kotlin – Spring Se...
loveprogramming viết 5 tháng trước
0 0
{{like_count}}

kipalog

{{ comment_count }}

bình luận

{{liked ? "Đã kipalog" : "Kipalog"}}


Male avatar
{{userFollowed ? 'Following' : 'Follow'}}
545 bài viết.
97 người follow

 Đầu mục bài viết

Vẫn còn nữa! x

Kipalog vẫn còn rất nhiều bài viết hay và chủ đề thú vị chờ bạn khám phá!