Code working.Solved problem in new version.
# Spring Security Project with JWT
This project demonstrates how to implement authentication and authorization using Spring Security with JSON Web Tokens (JWT) in a Spring Boot 3 application.
## Features
- User registration and login endpoints
- JWT generation and validation
- Secure API endpoints using JWT
- Role-based authorization
## Technologies Used
- Spring Boot 3
- Spring Security
- JSON Web Tokens (JWT)
- Maven
## Getting Started
### Prerequisites
- Java Development Kit (JDK) 11 or higher
- Maven
### Installation
1. Clone the repository:
```bash
git clone https://github.com/tamerlankayak/SpringSecurityJWT.git
-
Change to the project directory:
cd spring-security-jwt
-
Build the application:
mvn clean install
-
Open the
application.properties
file located in thesrc/main/resources
directory. -
Modify the database configuration properties according to your setup. For example:
spring.datasource.url=jdbc:mysql://localhost:3306/mydatabase spring.datasource.username=db_user spring.datasource.password=db_password
-
Save the changes.
-
Run the application:
mvn spring-boot:run
-
The application will start on
http://localhost:8080
. -
Use a tool like Postman to interact with the API endpoints.
Note: To access the protected resource, include the JWT in the request header using the Authorization
header with the value Bearer <JWT>
, where <JWT>
is the token obtained after successful authentication.
Contributions are welcome! Please follow the steps below to contribute to this project:
- Fork the repository.
- Create a new branch:
git checkout -b my-branch-name
. - Make your modifications and commit changes:
git commit -am 'Add some feature'
. - Push to the branch:
git push origin my-branch-name
. - Submit a pull request.
Make sure to update the placeholders such as `your-username` in the clone URL and customize other sections according to your project. Also, remember to include the appropriate license file (e.g., `LICENSE`) in your repository.