JWT-Authentication

This project is demonstrates how to implement JWT (JSON Web Token) based authentication in springboot.

Stars
4
  • Entity: Defines the data model and maps it to the database.
  • DTO (Data Transfer Object): Facilitates the transfer of data between different layers of the application.
  • Repository: Handles all database operations and data persistence.
  • Service: Contains the business logic and interacts with the Repository layer.
  • Config: Configures security settings, including JWT authentication and authorization.
  • Controller: Manages incoming HTTP requests, processes them, and returns appropriate responses.
  • Util: Contains utility classes for various operations, particularly for handling JWT tokens.
  • JWT Generation: Generates JWT tokens upon successful authentication, which are then used for securing subsequent requests.
  • User Authentication: Validates user credentials and issues JWT tokens, ensuring secure access to protected resources.
  • Spring Boot: Framework to create standalone, production-grade Spring-based applications.
  • Spring Security: Provides authentication and authorization support, securing the application.
  • JSON Web Token (JWT): Mechanism for securely transmitting information between parties as a JSON object.
  • JPA/Hibernate: ORM (Object Relational Mapping) framework to interact with the database.
  • MySQL (or any other database): Relational database for storing application data.
  • Maven: Build automation tool for managing project dependencies.
  • JDK 17 or later: Ensure that your system is running Java Development Kit 17 or a later version.
  • Maven 3.6 or later: Maven is required to manage dependencies and build the project.
  • MySQL (or any other database): A database to store application data.
  • IDE: Use an Integrated Development Environment like IntelliJ IDEA or Eclipse for development.
git clone https://github.com/sandundil2002/JWT-Authentication.git
cd JWT-Authentication
  • Update the application.properties file with your database connection details.

    spring.application.name=JWT-Authentication
    spring.datasource.url = jdbc:mysql://localhost:3306/yourDatabaseName?createDatabaseIfNotExist=true&allowPublicKeyRetrieval=true&useSSL=false
    spring.datasource.username=yourDatabaseUsername
    spring.datasource.password = yourDatabasePassword
    spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL8Dialect
    spring.jpa.hibernate.ddl-auto = update
    spring.datasource.driver-class-name =com.mysql.cj.jdbc.Driver
    spring.jpa.open-in-view=false
    spring.jpa.show-sql= true
    jwt.secret=e#s$p%o$r^t9
    
mvn clean install
mvn spring-boot:run

Postman API Documentation