This project is a simple login page implemented using Spring Boot. Below are some key details about the project:
The login page utilizes a PostgreSQL database for storing user credentials and other relevant information.
The login form is created using spring-boot-starter-security, which provides robust authentication and authorization features out of the box.
This project is built with Spring Boot version 3.2.3.
Access to Home page2 is restricted to users with the ROLE_ADMIN privilege.
Before running this project, make sure you complete the following steps:
- Enter database name, username and password in "application.properties" file.
- In your database create the following table
CREATE TABLE usert (id int primary key,
username varchar(100),
password varchar(100),
role varchar(100));
- In your database insert the user details
INSERT INTO usert (id, username, password, role) values
(1, 'user1', '$2a$10$Rd0QuZhnLMVBzmJRkm3vNujZiTzUBhmxh0Rdd0XAPoMyb10K5YwmG', 'ROLE_USER'), --password = pass1
(2, 'user2', '$2a$10$FzdzNyXJIn1nRIKXRLLWmOmmSFLBdvMQgaMO6kdPHpvg94Vth0H52', 'ROLE_USER'), --password = pass2
(3, 'admin', '$2a$10$z303SZBL1330WhDyuMvltuA/Q0OlK6Bc4wdWRqewvIoX0JksYvCWq', 'ROLE_ADMIN'); --password = pass3
The passwords are encoded using the Bcrypt hashing method.
You can use a tool like (https://www.browserling.com/tools/bcrypt) to generate bcrypt hashes for passwords.
For example, for the password pass1 with 10 rounds, the bcrypt hash is $2a$10$Rd0QuZhnLMVBzmJRkm3vNujZiTzUBhmxh0Rdd0XAPoMyb10K5YwmG.