Kotlin – Spring Security JDBC Authentication – SpringBoot + MySQL + Bootstrap

https://grokonez.com/spring-framework/spring-boot/kotlin-spring-boot/kotlin-spring-security-jdbc-authentication-springboot-mysql-bootstrap

Kotlin – Spring Security JDBC Authentication – SpringBoot + MySQL + Bootstrap

In the tutorial, JavaSampleApproach will show you how to create a Kotlin Spring Security JDBC Authentication with SpringBoot + MySQL + Bootstrap.

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

  • MySQL

    II. Goal

    We create a Kotlin MVC Web Application as below:

Kotlin Spring Security JDBC Authentication - project structure

With 5 urls:

– ‘/’: access with everyone.

Kotlin Spring Security JDBC Authentication - home pagepng

– ‘/user’: must authenticate and be accessed with user ROLE {USER, ADMIN}

Kotlin Spring Security JDBC Authentication - users

– ‘/admin’: accessed by user with role Admin

Kotlin Spring Security JDBC Authentication - admin

– ‘/login’: login page

Kotlin Spring Security JDBC Authentication - login

– ‘/403’: HTTP Error 403 Forbidden

Kotlin Spring Security JDBC Authentication - access-denied

We create 2 MySQL tables for 2 users (username/password):

  • jack/jack has 2 roles {USER, ADMIN}
  • peter/peter has 1 role USER

Kotlin Spring Security JDBC Authentication - tables

-> jack/jack can access both pages {user.html, admin.html}. While peter/peter just accesses 1 page user.html.

III. Implementation

– Create Kotlin Spring Boot project
– Create Controller
– Create View Pages
– Configure Database
– Configure WebSecurity

1. Create Kotlin Spring Boot project

Use SpringToolSuite to create a Kotlin SpringBoot project with below dependencies:

More at:

https://grokonez.com/spring-framework/spring-boot/kotlin-spring-boot/kotlin-spring-security-jdbc-authentication-springboot-mysql-bootstrap

Kotlin – Spring Security JDBC Authentication – SpringBoot + MySQL + Bootstrap

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 1 năm 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 11 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 11 tháng trước
1 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á!