- JWT-based authentication (OAuth2 ready)
- Token validation middleware
- Proxying/forwarding to internal services
- Request/response transformation
- Role/permission middleware
- Basic service health-check endpoints
Pull from Docker Hub:
docker pull theisaac/django_authentication_gateway:latest- Python 3.9+
- Django 4.2+
- PostgreSQL / MySQL
# 1. Clone repo
git clone https://github.com/Mount-Isaac/django_authentication_gateway.git
cd django_authentication_gateway
# 2. Virtual environment
python -m venv venv
source venv/bin/activate # or venv\Scripts\activate for Windows
# 3. Install deps
pip install -r requirements.txt
# 4. Configure .env: rename the .env.example file & populate with the correct credentials
cp .env.example .env
# 4. Run the application
python manage.py runserver 1819DEBUG=False
SECRET_KEY=your-django-secret
DATABASE_URL=postgres://user:password@localhost/db
JWT_SECRET_KEY=your-jwt-secretDefine services in config.yaml or directly in settings.py:
microservices:
orders:
url: http://localhost:5000
timeout: 30
authorization: true
forward:
headers: true
body: true
params: true
users:
url: http://localhost:5001
timeout: 30
authorization: false
forward:
headers: true
body: false
params: true
inventory:
url: http://localhost:5002
timeout: 45
authorization: true
forward:
headers: true
body: true
params: truePOST /api/auth/token/— get a JWT token- Add header:
Authorization: Bearer <token> - Gateway validates token
- Routes request to correct microservice
{
"success": True,
"message": "Action completed successfully",
"data": {...},
"meta": { "request_id": "...", "timestamp": "..." }
}{
"success": False,
"message": "Order not found",
"code": 404,
"errors": {
"type": "NotFoundError",
"details": "Order with ID 9876 not found"
},
"meta": { "request_id": "...", "timestamp": "..." }
}| Endpoint | Description |
|---|---|
/health/ |
Gateway health check |
/metrics/ |
Performance stats |
/services/status/ |
Microservice availability |
# Install dev tools
pip install -r requirements-dev.txt
# Run tests
python manage.py test- Register it in
microservicesconfig.yaml - Set up any auth or routing rules if needed
- Deploy and test
- Use HTTPS in production
- Short-lived access tokens
- Rate limiting (via caching or middleware)
- Header sanitization
- IP + request logging
- Email: isadechair019@gmail.com
- WhatsApp: Chat Now
Start multiple Django apps at once:
for app in app1 app2 app3; do python manage.py startapp $app; done