SpringJWT is a demo project designed to help developers understand how to implement JWT (JSON Web Token) authentication with Spring Security. This project showcases a backend solution using bearer tokens for secure authentication and includes a sample frontend for testing purposes.
- JWT Authentication: Secure user authentication using JWT bearer tokens.
- Spring Security Integration: Leveraging Spring Security to manage user access.
- Token Generation and Validation: Supports token issuance and validation with secure key management.
- Sample Frontend: A basic frontend provided for testing authentication and secure routes.
- Custom Exception Handling: Handles invalid credentials and other security exceptions.
src/
├── main/
│ ├── java/lk/ijse/jwt/
│ │ ├── config/
│ │ ├── controller/
│ │ ├── dto/
│ │ ├── entity/
│ │ ├── repository/
│ │ ├── service/
│ │ ├── util/
│ └── resources/
│ └── application.properties
└── templates/
- JWT Token Generation: After successful login or registration, the backend generates a JWT token using user credentials.
- Token Validation: For secure routes, the token is validated to authenticate the user.
- Role-Based Authorization: Different user roles can access specific routes based on the token.
- Sample Frontend Testing: The frontend helps test login and authentication flow.
- Java 11+
- Maven
- Spring Boot
- MySQL (or any compatible database)
- Postman (for API testing)
git clone https://github.com/gayanukabulegoda/SpringJWT.git
Edit application.properties
to set your MySQL connection details:
spring.datasource.url=jdbc:mysql://localhost:3306/springjwt
spring.datasource.username=YOUR_USERNAME
spring.datasource.password=YOUR_PASSWORD
mvn clean install
mvn spring-boot:run
The backend will start running at http://localhost:8080
.
The project includes a simple frontend to test JWT authentication.
Postman Documentation: API Documentation
This project is licensed under the MIT License - see the LICENSE file for details.
© 2024 Gayanuka Bulegoda