The IPDR Backend is a FastAPI-based service designed to manage and store NAT logs from MikroTik PPPoE users. It utilizes Elasticsearch for efficient log storage and retrieval and provides secure authentication mechanisms.
- FastAPI-powered backend
- Stores NAT logs in Elasticsearch
- Secure authentication with OAuth 2.0, LDAP, and SAML
- Multi-tenancy support
- RESTful API endpoints for log retrieval
- Role-based access control for law enforcement agencies
- Ubuntu 22.04
- Python 3.10+
- Elasticsearch 8+
- Redis (for caching, optional)
- Nginx (as a reverse proxy, optional)
cd /var/www
git clone https://github.com/imrankhan-coder/ipdr-backend.git
cd ipdr-backend
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
Create a .env
file in the root directory:
ELASTICSEARCH_HOST=http://localhost:9200
ELASTICSEARCH_INDEX=ipdr-logs
SECRET_KEY=your-secret-key
AUTH_METHOD=oauth2 # Options: oauth2, ldap, saml
LOG_RETENTION_DAYS=180
uvicorn main:app --host 0.0.0.0 --port 8000 --reload
sudo nano /etc/systemd/system/ipdr-backend.service
Add the following content:
[Unit]
Description=IPDR Backend FastAPI Service
After=network.target
[Service]
User=root
WorkingDirectory=/var/www/ipdr-backend
ExecStart=/var/www/ipdr-backend/venv/bin/uvicorn main:app --host 0.0.0.0 --port 8000
Restart=always
[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable ipdr-backend
sudo systemctl start ipdr-backend
GET /logs
- Retrieve stored NAT logsPOST /logs
- Store new logsGET /auth/me
- Get current user detailsPOST /auth/login
- Authenticate user
Check logs using:
sudo journalctl -u ipdr-backend --no-pager --lines=50
Pull requests are welcome. Please follow the coding standards and provide detailed commit messages.
This project is licensed under the MIT License.