Plug and play OTP authentication for African telecom providers
Project description
AfriAuth
🚀 Plug-and-play SMS OTP authentication for FastAPI powered by Africa’s Talking.
AfriAuth helps developers quickly integrate secure OTP authentication, phone verification, login flows, and SMS-based authentication into FastAPI applications with minimal setup.
Built for African startups, fintechs, SaaS platforms, and mobile-first applications.
✨ Why AfriAuth?
Most developers spend days building:
- OTP generation
- SMS delivery
- OTP verification
- retry protection
- expiration handling
- rate limiting
- authentication flows
- Redis session storage
Afriauth solves this in minutes.
⚡ Features
🔐 SMS OTP Authentication
Send and verify OTP codes instantly using Africa’s Talking.
⚡ FastAPI Integration
Built specifically for FastAPI with async support.
🧠 Automatic OTP Management
Handles:
- OTP generation
- expiration
- retries
- verification
- cleanup
🚦 Rate Limiting
Prevent abuse and SMS spam automatically.
🔒 Secure by Default
Includes:
- hashed OTP storage
- expiration windows
- brute-force protection
- replay prevention
📦 Redis Support
Store OTP sessions efficiently with Redis.
🧩 Plug-and-Play API Routes
Auto-generate authentication endpoints.
🌍 Africa’s Talking Integration
Optimized for African telecom infrastructure.
🔄 Extensible Provider System
Future support planned for:
- WhatsApp OTP
📦 Installation
pip install afri-auth-sms
🚀 Quick Start
1. Initialize Afriauth
from afri_auth import OTPAuth
otp = OTPAuth(
username="sandbox",
api_key="xxxx"
)
await otp.send_otp("+255694021848")
result = await otp.verify_otp(
"+255694021848",
"123456"
)
📲 Send OTP
await auth.send_otp("+255694021848")
✅ Verify OTP
is_valid = await auth.verify_otp(
phone="+255694021848",
code="123456"
)
print(is_valid)
⚡ FastAPI Example
from fastapi import FastAPI
from afri_auth.fastapi import OTPRouter
app = FastAPI()
app.include_router(
OTPRouter,
prefix="/auth"
)
Boom user will get
POST /auth/send-otp
POST /auth/verify-otp
OTP generation
OTP expiry
Redis storage
SMS sending
Rate limiting
Retry protection
Africa's Talking integration
⚙️ Redis Configuration
auth = AfriAuth(
username="sandbox",
api_key="YOUR_API_KEY",
redis_url="redis://localhost:6379"
)
Redis for ubuntu
sudo apt install redis-server
sudo systemctl start redis
immediately you will get
POST /auth/send-otp
POST /auth/verify-otp
No coding required for sending and verification
🔒 Security Features
Afriauth includes built-in:
- OTP expiration
- retry limits
- rate limiting
- secure OTP hashing
- brute-force prevention
- replay protection
⏳ OTP Expiration
Default:
5 minutes
Custom configuration:
auth = AfriAuth(
otp_expiry=300
)
🚦 Rate Limiting
Example:
auth = AfriAuth(
max_requests_per_minute=3
)
🧠 Custom SMS Templates
await auth.send_otp(
"+255712345678",
template="Your verification code is {code}"
)
🧩 Planned Features
✅ Upcoming
- CLI project generator
- Authentication starter kits
- WhatsApp OTP
- Email OTP
- PIN authentication
- biometric-ready flows
- multi-provider support
- user session management
- Docker deployment templates
🏗️ Planned CLI
afriauth init
Generate:
project/
├── main.py
├── auth/
├── routes/
├── redis/
├── docker-compose.yml
└── .env
🌍 Built for African Developers
Afriauth is designed for:
- fintech apps
- mobile money platforms
- SACCO systems
- startups
- e-commerce
- mobile-first apps
- telecom applications
🔗 Africa’s Talking Support
Current provider support:
- SMS OTP
- phone verification
- authentication messaging
More integrations coming soon.
📖 Documentation
Documentation coming soon.
🤝 Contributing
Contributions, ideas, and feature requests are welcome.
Feel free to open issues and pull requests.
📜 License
MIT License
❤️ Vision
Afriauth aims to become the authentication infrastructure layer for African developers.
Simple. Fast. Secure. Built for Africa.
NEW SAMPLE
Afri Auth
Plug and play OTP authentication package for African telecom providers.
Installation
pip install afri-auth-sms
Project structure
tree -L 3
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file afri_auth_sms-0.1.2.tar.gz.
File metadata
- Download URL: afri_auth_sms-0.1.2.tar.gz
- Upload date:
- Size: 7.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0f7f520848f152e7f1766a707ecc97a763fc2d885ae198620fc93e09750328f5
|
|
| MD5 |
838ce72739cb08f65166c293463b50e4
|
|
| BLAKE2b-256 |
3781dcb17342db38833e0a2086cb27dbd7ff591f589422161e0122b818693373
|
File details
Details for the file afri_auth_sms-0.1.2-py3-none-any.whl.
File metadata
- Download URL: afri_auth_sms-0.1.2-py3-none-any.whl
- Upload date:
- Size: 7.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ac74c16812579dd4f8e072b7a22b1a4ead48b4ab18bb8b9e9541f06cacab7cce
|
|
| MD5 |
79689c9ef4e9efac1d9541e5170c39ba
|
|
| BLAKE2b-256 |
d068f1cdd3e12e1f7c6035fb2dc9db3204b77516144d85df1b57bd4715d5f7e1
|