Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gayanukabulegoda/springjwt
SpringJWT is a simple project designed to help users understand JWT implementation with Spring Security, including the use of bearer tokens for secure authentication.
https://github.com/gayanukabulegoda/springjwt
authentication backend-auth bearer-token java-auth java-security jwt jwt-auth jwt-bearer-authentication jwt-token learn-security spring spring-authentication spring-boot spring-jwt spring-jwt-authentication spring-jwt-sample spring-security spring-security-jwt springjwt web-security
Last synced: about 9 hours ago
JSON representation
SpringJWT is a simple project designed to help users understand JWT implementation with Spring Security, including the use of bearer tokens for secure authentication.
- Host: GitHub
- URL: https://github.com/gayanukabulegoda/springjwt
- Owner: gayanukabulegoda
- License: mit
- Created: 2024-08-27T13:14:07.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2024-09-24T19:28:47.000Z (about 2 months ago)
- Last Synced: 2024-10-24T11:31:49.408Z (24 days ago)
- Topics: authentication, backend-auth, bearer-token, java-auth, java-security, jwt, jwt-auth, jwt-bearer-authentication, jwt-token, learn-security, spring, spring-authentication, spring-boot, spring-jwt, spring-jwt-authentication, spring-jwt-sample, spring-security, spring-security-jwt, springjwt, web-security
- Language: Java
- Homepage:
- Size: 24.4 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SpringJWT
**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.
## Features
- **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.## Project Structure
```
src/
├── main/
│ ├── java/lk/ijse/jwt/
│ │ ├── config/
│ │ ├── controller/
│ │ ├── dto/
│ │ ├── entity/
│ │ ├── repository/
│ │ ├── service/
│ │ ├── util/
│ └── resources/
│ └── application.properties
└── templates/
```## How It Works
1. **JWT Token Generation**: After successful login or registration, the backend generates a JWT token using user credentials.
2. **Token Validation**: For secure routes, the token is validated to authenticate the user.
3. **Role-Based Authorization**: Different user roles can access specific routes based on the token.
4. **Sample Frontend Testing**: The frontend helps test login and authentication flow.## Requirements
- **Java 11+**
- **Maven**
- **Spring Boot**
- **MySQL** (or any compatible database)
- **Postman** (for API testing)## Getting Started
### 1. Clone the repository
```bash
git clone https://github.com/gayanukabulegoda/SpringJWT.git
```
### 2. Configure the Application
Edit `application.properties` to set your MySQL connection details:
```bash
spring.datasource.url=jdbc:mysql://localhost:3306/springjwt
spring.datasource.username=YOUR_USERNAME
spring.datasource.password=YOUR_PASSWORD
```
### 3. Build and Run the Application
```bash
mvn clean install
mvn spring-boot:run
```
The backend will start running at `http://localhost:8080`.### 4. Frontend Testing
The project includes a simple frontend to test JWT authentication.### 5. API Documentation
Postman Documentation: [API Documentation](https://documenter.getpostman.com/view/36681432/2sAXqwXeJP)## License
This project is licensed under the **MIT License** - see the [LICENSE](LICENSE) file for details.##
© 2024 Gayanuka Bulegoda