Spring Boot Security Project Implimentation With Thymeleaf
This is a Spring Boot project that demonstrates how to set up authentication and authorization using Spring Security, along with other common dependencies like Maven, MySQL, Thymeleaf, and Spring Boot Web.
This project serves as a foundation for implementing Spring Security in your web application. It provides a basic structure for user authentication and role-based access control.
Before you begin, ensure you have met the following requirements:
- Java Development Kit (JDK) 8 or higher
- Apache Maven installed
- MySQL database server
- Your favorite Integrated Development Environment (IDE) or text editor
-
Clone this repository to your local machine using:
git clone https://github.com/your-username/spring-security-demo.git
-
Create a MySQL database and update the database configuration in
src/main/resources/application.properties
:spring.datasource.url=jdbc:mysql://localhost:3306/your_database_name spring.datasource.username=your_username spring.datasource.password=your_password
-
Build the project using Maven:
mvn clean install
- Security configuration can be found in
src/main/java/com/example/securitydemo/config/SecurityConfig.java
. Modify this file to configure your security settings, such as custom login pages, access control, or authentication providers.
This project includes an SQL script to create the necessary database and schemas. Follow these steps to set up the database:
-
Open your preferred MySQL client or command-line tool.
-
Create a new database using the MySQL client or command-line:
CREATE DATABASE your_database_name;
-
Use the newly created database:
USE your_database_name;
-
Execute the SQL script provided in the project to create the required tables and schemas. You can find the script in
Spring_Boot_Security_Project /Join_of_users_authorities.sql
.Replace
/path/to/your/project
with the actual path to your project directory. -
EER Diagram For Tabels:
-
Your database is now set up with the necessary tables and schemas for this project.
Make sure to update the spring.datasource.url
, spring.datasource.username
, and spring.datasource.password
properties in the application.properties
file with the correct database connection details.
For more advanced database configurations or if you encounter any issues, refer to the Spring Boot documentation on configuring databases.
-
Run the application using Maven:
mvn spring-boot:run
-
Access the application in your web browser at
http://localhost:8080
. -
You can log in with the following default credentials:
- Username:
user
- Password:
password
- Username:
-
Explore the application and customize it to your needs. You can add more roles, users, and protected resources as required.
Contributions are welcome! If you find any issues or have improvements to suggest, please open an issue or create a pull request on GitHub.