This is a Spring Boot project demonstrating JWT (JSON Web Token) authentication.
This project showcases how to implement JWT authentication in a Spring Boot application. It provides endpoints for user registration and authentication using JWT tokens.
- User registration and login with JWT authentication
- JWT token generation and authentication
- Stateless authentication using JWT
- Customizable security configuration
- Session management
- Password encryption using BCrypt
- Role-based authorization with Spring Security
- Java Development Kit (JDK) 17 or higher
- Maven 3 or higher
- MySQL or any other database for storing user data
-
Clone the repository:
git clone https://github.com/AtulSingh11-0/jwt-SpringBoot.git
-
Navigate to the project directory:
cd jwt-SpringBoot
-
Build the project:
mvn clean install
-
Configure the database connection in
application.properties
:spring.datasource.url=jdbc:mysql://localhost:3306/mydatabase spring.datasource.username=myuser spring.datasource.password=mypassword
-
Configure other application properties as needed.
-
Run the application:
mvn spring-boot:run
Your application will be live and runnning at http://localhost:8080.
-
Access the endpoints as described in the Endpoints section.
POST /api/v1/auth/register
: Register a new user.POST /api/v1/auth/login
: Authenticate a user and generate JWT token.GET /api/v1/demo/hello
: This route can only be accessed after authenticationGET /api/v1/unsecured/hello
: This route doesnt need any authentication to be accessed