-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e619425
commit 8ee0e3d
Showing
1 changed file
with
65 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,65 @@ | ||
# spring-security-jwt | ||
# spring-security-jwt | ||
|
||
This repository contains an example Spring project implementing authentication and authorization using Spring Security with JWT. The project provides a set of APIs for user registration, login, and role-based access control. | ||
|
||
## Features | ||
|
||
- **User Registration**: Allows new users to sign up by providing necessary details. | ||
- **User Login**: Authenticates users and provides a JWT token for subsequent requests. | ||
- **Role-Based Access Control**: Access control for specific endpoints based on user roles (`MASTER` and `USER`). | ||
|
||
## APIs | ||
|
||
The following endpoints are available: | ||
|
||
- **User Signup** | ||
- **Endpoint**: `/signup` | ||
- **Method**: `POST` | ||
- **Description**: Registers a new user. | ||
- **Request Body**: `SignupRequestDto` (required) | ||
|
||
- **User Login** | ||
- **Endpoint**: `/sign` | ||
- **Method**: `POST` | ||
- **Description**: Authenticates a user and returns a JWT token. | ||
- **Request Body**: `LoginRequestDto` (required) | ||
|
||
- **Admin Only Access** | ||
- **Endpoint**: `/admin` | ||
- **Method**: `GET` | ||
- **Description**: Grants access to users with the `MASTER` role. | ||
- **Authorization**: Requires `MASTER` role. | ||
|
||
- **User Only Access** | ||
- **Endpoint**: `/user` | ||
- **Method**: `GET` | ||
- **Description**: Grants access to users with the `USER` role. | ||
- **Authorization**: Requires `USER` role. | ||
|
||
## Setup Instructions | ||
|
||
1. **Development Environment** | ||
To run the project in a development environment, execute the following: | ||
```bash | ||
docker-compose -f docker-compose.dev.yml up | ||
``` | ||
|
||
2. **Production Deployment** | ||
To deploy in production, update the `.env` file with appropriate production configurations, then run: | ||
```bash | ||
docker-compose -f docker-compose.prod.yml up | ||
``` | ||
|
||
## API Documentation | ||
|
||
The project includes Swagger API documentation, accessible at: | ||
``` | ||
/docs | ||
``` | ||
|
||
## Dependencies | ||
|
||
- Spring Boot | ||
- Spring Security | ||
- JWT | ||
- Swagger (for API documentation) |