From the Udemy Course from Chad Derby : Spring Boot 3, Spring 6 & Hibernate for Beginners
This project is a Spring Boot application designed to demonstrate the integration of Spring Security for authentication and authorization processes. It showcases various security configurations using Thymeleaf as the template engine for rendering views.
The project is organized into several Java packages and resources:
com.luve2code.springboot.demosecurity
- Contains the main application and configuration classes.com.luve2code.springboot.demosecurity.controller
- Contains the controllers for handling user requests.resources/templates
- Contains Thymeleaf HTML templates for the UI.
There are two main controllers in this application:
DemoController
- Manages the routes for the home, leaders, and systems pages.LoginController
- Manages authentication views and the access-denied page.
The application uses Spring Security for managing user authentication and authorization based on roles. It demonstrates handling of login and logout functionalities and restricts access based on user roles.
- Java 17
- Maven
- MySQL
-
Database Setup
- Ensure MySQL is running on your local machine.
- Create a database named
employee_directory
and import the initial setup SQL scripts from thesql-scripts
directory.
-
Build and Run
- Navigate to the root directory of the project via command line.
- Execute the following Maven command to run the application:
mvn spring-boot:run
-
Access the Application
- Open a web browser and navigate to
http://localhost:8080
to access the application. - Use the following credentials to log in:
- Username:
mary
orsusan
orjohn
- Password:
fun123
- Username:
- Open a web browser and navigate to
- User Authentication: Custom login and logout functionalities.
- Role-Based Access Control: Different views and functionalities based on user roles (
EMPLOYEE
,MANAGER
,ADMIN
). - Thymeleaf Integration: Use of Thymeleaf templates for rendering HTML content dynamically based on the security context.