Skip to content

Secure platform designed for user registration, login, and password restoration. It is built using a combination of Spring Boot, Spring Security, PostgreSQL, JWT, and Vue.js.

Notifications You must be signed in to change notification settings

AhmedBAKKARI/Secure-User-Platform-with-SpringBoot3-Vue-JWT

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

63 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Secure Platform with Spring Boot 3, Spring Security 6, PostgreSQL, JWT and Vue.js


Assalaam-Alaikum ---- السَّلامُ عَلَيْكُم ورَحْمَةُ اللهِ وَبَرَكاتُهُ

Welcome to the Secure Platform with Spring Boot 3, Spring Security 6, PostgreSQL, JWT and Vue.js project.
This project is a secure platform designed for user registration, login, and password restoration. It is built using a combination of Spring Boot, Spring Security, PostgreSQL, JWT (JSON Web Tokens), and Vue.js.

Introduction

In today's digital world, ensuring the security of user information is of utmost importance. This platform provides a robust and reliable solution for managing user authentication and access control. Whether you are developing a web application, a mobile app, or any system that requires user management, this project provides a solid foundation.

Table of Content

Technologies Used

Those are the main technologies used in this project: main tech used

The following are in details technologies used to build this application:
✅ Java 17
✅ Spring Boot 3
✅ Spring Security 6
✅ Spring Data JPA
✅ Docker
✅ PostgreSQL
✅ JUnit
✅ Mockito
✅ JWT
✅ Vue.js
✅ Vue router
✅ Pinia

Requirements

  • Having Java 17 or later installed.
    You can download it from Oracle's website.

  • Having PostgreSQL DataBase installed, or you can fire up an instance of PostgreSQL using the docker-compose file provided in the project.
    Install PostgreSQL from PostgreSQL's website.

  • Having Node.js installed.
    You can download it from Node.js's website.

Installation

  1. Clone this repository to your local machine using this command :
    git clone https://github.com/NidhalNaffati/SpringSecurity_SpringBoot6_Vue3_JWT.git
  2. Import the project into your IDE.
  3. Open the application.yml file located in src/main/resources/ and update the database credentials with your own.
spring:
datasource:
  url: jdbc:postgresql://${POSTGRES_HOST:localhost}:${POSTGRES_PORT:5432}/${POSTGRES_DB:postgres} # if the host is not specified, it will be localhost, if the port is not specified, it will be 5432 and if the database is not specified, it will be postgres
  username: ${POSTGRES_USER:postgres} # if the username is not specified, it will be postgres
  password: ${POSTGRES_PASSWORD:postgres} # if the password is not specified, it will be postgres
  redis:
  host: ${REDIS_HOST:localhost} # if the host is not specified, it will be localhost
  port: ${REDIS_PORT:6379} # if the port is not specified, it will be 6379
  time-to-live: 60 # the time to live in seconds
  1. Run the backend via your IDE, or using the Maven plugin mvn spring-boot:run.
  2. Run the frontend via your IDE, or using the following command npm run dev.

Architecture

Global Diagram of the application:

Diagram of the architecture of the spring security application:

architecture

Diagram of class of the application:

architecture

Endpoints

After running the application, you can use Postman to communicate with the REST API endpoints. Each endpoint expects a specific input format and returns a specific output format. If you want to test it out in Postman, you can import the collections located in src/test/postman/

The following endpoints are available in the API:

Public endpoints that do not require authentication:

HTTP Method Endpoint Request Body Response Body Exception(s) Authorization Header Description
POST /api/v1/auth/register RegisterRequest String PasswordDontMatchException
EmailAlreadyExistsException
MailSendException
Exception
- Registers a new user.
POST /api/v1/auth/authenticate AuthenticationRequest AuthenticationResponse - - Authenticates a user and returns an authentication token.
POST /enable-user/{token} String String ExpiredJwtException
UserNotFoundException
Exception
- Enables a user account with the provided activation token.
POST /api/v1/auth/refresh-token HttpServletRequest, HttpServletResponse AuthenticationResponse - Bearer {token} Refreshes the authentication token for the current user.
POST /api/v1/auth/forgot-password EmailRequest String UserNotFoundException
MailSendException
Exception
- Sends a reset password link to the user's email.
POST /api/v1/auth/reset-password UpdatePasswordRequest String PasswordDontMatchException
ExpiredJwtException
UserNotFoundException
Exception
- Resets the user's password with the provided token and new password.

Endpoints that require authentication:

HTTP Method Endpoint Request Body Response Body Authorization Header Exception(s) Description
GET /api/v1/admin - String Bearer {token} AccessDeniedException Return a message for an admin
GET /api/v1/user - String Bearer {token} AccessDeniedException Return a message for a user

Screen Shots

This is the landing page of the application.
landing_page

This is the login page of the application.
login

This is the login page showing an error message.
login_error

This is the register page of the application.
register

This is the Email received by the user, used to activate the account
reset-password

This is the forgot password page of the application.
forgot-password

This is the authenticated page of the application, all the authenticated users can access this page.
authenticated-page

This is the user page of the application, only the authenticated users can access this page.
user-page

This is the admin page of the application, only the authenticated users with the role admin can access this page.
admin-page

Contributing

  1. Fork this repository to your GitHub account.
  2. Clone the forked repository to your local machine.
  3. Create a new branch for your changes.
  4. Make your changes and commit them with descriptive commit messages.
  5. Push your changes to your GitHub account.
  6. Create a pull request from your branch to the original repository's main branch.
  7. Wait for the maintainers to review and merge your changes.

When making contributions, please keep the following in mind:

  • Follow the code style and formatting guidelines used in the project.
  • Write clear and concise commit messages that explain the changes you made.
  • Make sure your changes do not break existing functionality.
  • Write tests for new code and ensure that all existing tests pass.

License

You are allowed to use, copy, modify, and distribute the code freely, just don't create a bomb or something like that xD

About

Secure platform designed for user registration, login, and password restoration. It is built using a combination of Spring Boot, Spring Security, PostgreSQL, JWT, and Vue.js.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 70.1%
  • Vue 21.9%
  • JavaScript 5.1%
  • HTML 2.9%