Skip to content

Commit

Permalink
Task 64 : Devise README.md template
Browse files Browse the repository at this point in the history
  • Loading branch information
Rapter1990 committed Jul 21, 2024
1 parent 41f956b commit dac5b7e
Showing 1 changed file with 252 additions and 0 deletions.
252 changes: 252 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,252 @@
# Spring Boot Microservices with JWT Implementation

<p align="center">
<img src="screenshots/spring_boot_security_example_jwt_implementation.png" alt="Main Information" width="700" height="500">
</p>

### 📖 Information

<ul style="list-style-type:disc">
<li>This project demonstrates a <b>Spring Boot microservices</b> architecture with <b>JWT-based authentication</b> and <b>role-based</b> access control. The setup includes an <b>API Gateway</b> to manage <b>routing</b> and <b>authentication</b>.</li>
</ul>

<ul style="list-style-type:disc">
<li>Roles and Permissions:
<ul>
<li><b>Admin</b> and <b>User</b> roles each have their own authentication and authorization mechanisms defined by their roles.</li>
<li><b>Admin</b> can:
<ul>
<li>Create products</li>
<li>Retrieve all products</li>
<li>Retrieve products by ID</li>
<li>Update products by ID</li>
<li>Delete products by ID</li>
</ul>
</li>
<li><b>User</b> can:
<ul>
<li>Retrieve all products</li>
<li>Retrieve products by ID</li>
</ul>
</li>
</ul>
</li>
</ul>

### Explore Rest APIs

<table style="width:100%">
<tr>
<th>Method</th>
<th>Url</th>
<th>Description</th>
<th>Request Body</th>
<th>Header</th>
<th>Valid Path Variable</th>
<th>No Path Variable</th>
</tr>
<tr>
<td>POST</td>
<td>/api/v1/authentication/admin/register</td>
<td>Admin Register</td>
<td>AdminRegisterRequest</td>
<td></td>
<td></td>
<td></td>
<tr>
<tr>
<td>POST</td>
<td>/api/v1/authentication/admin/login</td>
<td>Admin Login</td>
<td>LoginRequest</td>
<td></td>
<td></td>
<td></td>
<tr>
<tr>
<td>POST</td>
<td>/api/v1/authentication/admin/refreshtoken</td>
<td>Admin Refresh Token</td>
<td>TokenRefreshRequest</td>
<td></td>
<td></td>
<td></td>
<tr>
<tr>
<td>POST</td>
<td>/api/v1/authentication/admin/logout</td>
<td>Admin Logout</td>
<td>TokenInvalidateRequest</td>
<td></td>
<td></td>
<td></td>
<tr>
<tr>
<td>POST</td>
<td>/api/v1/authentication/user/register</td>
<td>User Register</td>
<td>UserRegisterRequest</td>
<td></td>
<td></td>
<td></td>
<tr>
<tr>
<td>POST</td>
<td>/api/v1/authentication/user/login</td>
<td>User Login</td>
<td>LoginRequest</td>
<td></td>
<td></td>
<td></td>
<tr>
<tr>
<td>POST</td>
<td>/api/v1/authentication/user/refreshtoken</td>
<td>User Refresh Token</td>
<td>TokenRefreshRequest</td>
<td></td>
<td></td>
<td></td>
<tr>
<tr>
<td>POST</td>
<td>/api/v1/authentication/user/logout</td>
<td>User Logout</td>
<td>TokenInvalidateRequest</td>
<td></td>
<td></td>
<td></td>
<tr>
<tr>
<td>POST</td>
<td>/api/v1/products</td>
<td>Create Product</td>
<td>ProductCreateRequest</td>
<td></td>
<td></td>
<td></td>
<tr>
<tr>
<td>GET</td>
<td>/api/v1/products/{productId}</td>
<td>Get Product By Id</td>
<td></td>
<td></td>
<td>ProductId</td>
<td></td>
<tr>
<tr>
<td>GET</td>
<td>/api/v1/products</td>
<td>Get Products</td>
<td>ProductPagingRequest</td>
<td></td>
<td></td>
<td></td>
<tr>
<tr>
<td>PUT</td>
<td>/api/v1/products/{productId}</td>
<td>Update Product By Id</td>
<td>ProductUpdateRequest</td>
<td></td>
<td>ProductId</td>
<td></td>
<tr>
<tr>
<td>DELETE</td>
<td>/api/v1/products/{productId}</td>
<td>Delete Product By Id</td>
<td></td>
<td></td>
<td>ProductId</td>
<td></td>
<tr>
</table>


### Technologies

---
- Java 21
- Spring Boot 3.0
- Restful API
- Lombok
- Maven
- Junit5
- Mockito
- Integration Tests
- Docker
- Docker Compose
- Github Actions
- Spring Cloud
- Postman
- Spring Security
- JWT


### Prerequisites

#### Define Variable in .env file for product service and user service

```
DATABASE_USERNAME={DATABASE_USERNAME}
DATABASE_PASSWORD={DATABASE_PASSWORD}
```

---
- Maven or Docker
---


### Docker Run
The application can be built and run by the `Docker` engine. The `Dockerfile` has multistage build, so you do not need to build and run separately.

Please follow directions shown below in order to build and run the application with Docker Compose file;

```sh
$ cd springbootmicroserviceswithsecurity
$ docker-compose up -d
```

If you change anything in the project and run it on Docker, you can also use this command shown below

```sh
$ cd springbootmicroserviceswithsecurity
$ docker-compose up --build
```

---
### Maven Run
To build and run the application with `Maven`, please follow the directions shown below;

```sh
$ cd springbootmicroserviceswithsecurity
$ cd eurekaserver
$ mvn clean install
$ mvn spring-boot:run
$ cd ..
$ cd apigateway
$ mvn clean install
$ mvn spring-boot:run
$ cd ..
$ cd authservice
$ mvn clean install
$ mvn spring-boot:run
$ cd ..
$ cd userservice
$ mvn clean install
$ mvn spring-boot:run
$ cd ..
$ cd productservice
$ mvn clean install
$ mvn spring-boot:run
```

### Screenshots

<details>
<summary>Click here to show the screenshots of project</summary>
<p> Figure 1 </p>
<img src ="screenshots/spring_1.PNG">
</details>

0 comments on commit dac5b7e

Please sign in to comment.