Skip to content

sakibhasancse/Api-Gateway-With-Authentication

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Api gateway with nginx

image

Overview

This API gateway uses Nginex to handle authentication and route requests to backend services. When a user makes a request, the gateway authenticates the user and, upon successful authentication, forwards the request to the appropriate service. This setup centralizes authentication and simplifies service management.

1️⃣ Try on your device.

2️⃣ Run the Services

cd docker
docker-compose up --build -d

🚀 Try the API

🔹 Register a User

curl --location 'http://localhost:8080/auth/register' \
--header 'Content-Type: application/json' \
--data '{
    "username": "sakib",
    "password": "122"
}'

🔹 Login to Get Token

curl --location 'http://localhost:8080/auth/login' \
--header 'Content-Type: application/json' \
--data '{
    "username": "sakib",
    "password": "122"
}'
  • Response: { "token": "your-jwt-token" }

🔹 Access an Authenticated Route

curl --location --request GET 'http://localhost:8080/product/products' \
--header 'Authorization: Bearer your-token' \
--header 'Content-Type: application/json'

🛑 Stop Services

docker-compose down

Kong Implementation: https://github.com/sakibhasancse/ApiGatway/tree/kong-implementation

Releases

No releases published

Packages

No packages published