Kotlin - Spring Security - Persistent Token Remember-Me authentication » grokonez

Kotlin - Spring Security - Persistent Token Remember-Me authentication » grokonez

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. ContentsI. TechnologiesII. GoalIII. Implementation1. Create Kotlin SpringBoot project2. Create controller & viewsWebControllerhome.htmllogin.html3. Setup MySql database configuration4. Configure remember-me … Continue reading "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

kotlin spring-security

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Json Web Token: How to Secure a Spring Boot REST API - DZone Security

In this post, I show how to secure Spring Boot REST API using Json Web Tokens for authorization. We will also use Spring Security in this tutorial.

How to build a secure Grails 4 Application using Spring Security Core

In this Grails 4 tutorial, we will show you how to build a secure Grails 4 application using Spring Security Core Plugin. We will add the login and register function to the Grails 4 application.

How to Disable Spring Security Logout Redirects

Take a close look at how to disable logout redirects in Spring Security. In this short tutorial, we're going to take a close look at how to disable logout redirects in Spring Security.

Spring Security Tutorial For Beginners | Spring Security Basics

This Edureka video on Spring Security will help you understand the different security concepts implemented in the Spring framework with examples.

Best Custom Web & Mobile App Development Company

Top Web & Mobile Application Development Company in India & USA. We specialize in Golang, Ruby on Rails, Symfony, Laravel PHP, Python, Angular, Mobile Apps, Blockchain, & Chatbots