https://github.com/sunnysingh1231/security_configuration_with_jwt
This project implements JWT-based authentication using Spring Security. It provides secure user login, password encryption, and session handling with token-based authentication. Users can register with encrypted passwords and authenticate via JWT tokens to access protected endpoints.
https://github.com/sunnysingh1231/security_configuration_with_jwt
java spring-data-jpa spring-security springframework
Last synced: about 1 year ago
JSON representation
This project implements JWT-based authentication using Spring Security. It provides secure user login, password encryption, and session handling with token-based authentication. Users can register with encrypted passwords and authenticate via JWT tokens to access protected endpoints.
- Host: GitHub
- URL: https://github.com/sunnysingh1231/security_configuration_with_jwt
- Owner: Sunnysingh1231
- Created: 2025-01-11T05:00:40.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-29T02:28:34.000Z (about 1 year ago)
- Last Synced: 2025-04-09T22:57:57.560Z (about 1 year ago)
- Topics: java, spring-data-jpa, spring-security, springframework
- Language: Java
- Homepage:
- Size: 20.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Spring Security JWT Authentication API
## Description
This project implements authentication and authorization using **Spring Security** and **JWT (JSON Web Token)**. It includes user authentication, password encoding, and secure token-based access control.
## Features
- **JWT-based Authentication**: Secure login and session handling.
- **Spring Security Integration**: Protects endpoints using JWT.
- **User Registration**: Saves new users with encrypted passwords.
- **Session Handling**: Generates unique session IDs.
## Technologies Used
- **Spring Boot**
- **Spring Security**
- **JWT (JSON Web Token)**
- **Spring Data JPA**
- **MySQL Database**
- **Maven**
## Endpoints
### Public Endpoints
- `GET /hello` - Returns a greeting message with session ID.
- `GET /xtoken` - Returns token-related session info.
- `POST /login` - Authenticates user and generates JWT.
- `POST /post` - Registers a new user with encrypted password.
## Prerequisites
- JDK 17
- MySQL installed and running
- Postman (for testing API requests)
3. Configure **application.properties**:
```properties
spring.datasource.url=jdbc:mysql://localhost:3306/your_database
spring.datasource.username=root
spring.datasource.password=your_password
jwt.secret=your_secret_key
```
## Notes
- Ensure that the **database is created** before running the application.
- Use **JWT tokens** for authentication in secured endpoints.
- Passwords are securely stored using **BCrypt password encoding**.
## Author
This project is built for secure user authentication using **Spring Security and JWT**.