Skip to main content

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

Release files for afri-auth-sms 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for afri-auth-sms 0.1.2
File Size Uploaded
afri_auth_sms-0.1.2.tar.gz 7.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for afri-auth-sms 0.1.2
File Interpreter ABI Platform
afri_auth_sms-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size:15.0 kB

Release files / afri_auth_sms-0.1.2.tar.gz

Download URL afri_auth_sms-0.1.2.tar.gz
Size 7.9 kB
Tags Source
SHA-256 checksum
How to use checksums
0f7f520848f152e7f1766a707ecc97a763fc2d885ae198620fc93e09750328f5
BLAKE2b-256 checksum
How to use checksums
3781dcb17342db38833e0a2086cb27dbd7ff591f589422161e0122b818693373
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / afri_auth_sms-0.1.2-py3-none-any.whl

Download URL afri_auth_sms-0.1.2-py3-none-any.whl
Size 7.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ac74c16812579dd4f8e072b7a22b1a4ead48b4ab18bb8b9e9541f06cacab7cce
BLAKE2b-256 checksum
How to use checksums
d068f1cdd3e12e1f7c6035fb2dc9db3204b77516144d85df1b57bd4715d5f7e1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page