Kotlin – Spring Security – Persistent Token Remember-Me authentication

https://grokonez.com/spring-framework/spring-boot/kotlin-spring-boot/kotlin-spring-security-persistent-token-remember-authentication

Kotlin – Spring Security – Persistent Token Remember-Me authentication

Remember-me authentication is a solution for websites to remember the identity of an user between many sessions. In the tutorial, JavaSampleApppoach will show you how to configure persistent token remember-me authentication with Kotlin Spring Security web application.

I. Technologies

– Kotlin 1.2.20
– Apache Maven 3.5.2
– Spring Tool Suite – Version 3.9.2.RELEASE
– Spring Boot – 1.5.10.RELEASE
– Bootstrap
– MySQL database

II. Goal

We create a Kotlin SpringBoot MVC Web Application as below:

Kotlin Spring Security - Persistent Token Remember-Me authentication - project structure

We have a login page:

Kotlin Spring Security - Persistent Token Remember-Me authentication - login page

When make the firstly request: http://localhost:8080, login page will be redicted immediately, authenticate with an account user/user, but NOT check 'Remember me'
-> Result: Login successfully, having 1 cookie: JSESSIONID. No record in persistent_logins table

Kotlin Spring Security - Persistent Token Remember-Me authentication - session

– Delete JSESSIONID and make above request again: http://localhost:8080 -> login page will be re-directed immediately for authentication again.

Login with account: user/user, and check 'Remember me'
-> Authentication successfully. Having 2 cookies: JSESSIOINID & javasampleapproach-remember-me

Kotlin Spring Security - Persistent Token Remember-Me authentication - javasampleapproach session

-> 1 record in persistent_logins table

Kotlin Spring Security - Persistent Token Remember-Me authentication -table records

– Remove JSESSIONID cookie, then make the request: http://localhost:8080
-> NOT redirect to login page (because having javasampleapproach-remember-me cookie

– Remove JSESSIONID & javasampleapproach-remember-me cookie, then make the request: http://localhost:8080, login page will be redirected >>> Right!

It works fine!

III. Implementation

Step to do
– Create Kotlin SpringBoot project
– Create controller & views
– Setup MySql database configuration
– Configure remember-me security

1. Create Kotlin SpringBoot project

Use SpringToolSuite to create a Kotlin SpringBoot project with dependencies:

More at:

https://grokonez.com/spring-framework/spring-boot/kotlin-spring-boot/kotlin-spring-security-persistent-token-remember-authentication

Kotlin – Spring Security – Persistent Token Remember-Me authentication

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 12 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/springamqp/rabbitmqqueuedurabilitypersistentmessagedeliveryspringboot RabbitMq Queue Durability and Persisten...
loveprogramming viết 6 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á!