Kotlin – Spring Security – Customize Authentication Provider

In the post, we guide how to customize AuthenticationProvider for Kotin SpringSecurity web application.

I. Technology

– 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. SpringSecurity Authentication Provider

SpringSecurity provides an interface to customize Authentication:

Goal

Create a Kotlin SpringBoot project as below:

kotlin springsecurity - authentication provider - project structure

Login page:

kotlin springsecurity - authentication provider - login page

When login with accounts: {user/user, admin/admin} -> login successfully

-> console’s logs:

When login with others, example {peter/peter} -> login fail

-> console’s logs:

kotlin springsecurity - authentication provider - fail authentiaction

III. Implementation

Step to do
– Create Kotlin SpringSecurity project
– Customize Authentication Provider

1. Create Kotlin SpringSecurity project

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

2. Customize Authentication Provider

– CustomAuthenticationProvider:

– Configure ‘CustomAuthenticationProvider’ bean in ‘WebSecurityConfigurer’

IV. Sourcecode

KotlinSpringSecurityCustomizeAuthenticationProvider

By JavaSampleApproach | February 28, 2018.

Related Posts


Got Something To Say:

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

*