Kotlin – Spring Security – Customize Authentication Success Handler

In the tutorial, we will show you how to customize Authentication 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 SpringBoot MVC Web Application as below:

kotlin spring security - customize login successfully - project structure - project structure

We have a login page:

kotlin spring security - customize login successfully - project structure - login form

When login successfully with admin/admin account, it will redirect to /admin:

kotlin spring security - customize login successfully - project structure - admin

When login successfully with user/user account, it will redirect to /user:

kotlin spring security - customize login successfully - project structure - user

How to achieve it?
-> We will customize AuthenticationSuccessHandler.

III. Implementation

1. Create Kotlin Spring Security web application

-> Follow the article: Kotlin SpringBoot – Configure Spring Security

2. Customize AuthenticationSuccessHandler
2.1 Customize AuthenticationSuccessHandler

2.2 Add AuthenticationSuccessHandler to WebSecurityConfigurer

IV. SourceCode

KotlinSpringSecurity

By grokonez | February 17, 2018.



Related Posts


Got Something To Say:

Your email address will not be published. Required fields are marked *

*