Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

afri_auth_sms-0.1.1.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

afri_auth_sms-0.1.1-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file afri_auth_sms-0.1.1.tar.gz.

File metadata

  • Download URL: afri_auth_sms-0.1.1.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for afri_auth_sms-0.1.1.tar.gz
Algorithm Hash digest
SHA256 e2ff7133f6a026b6ace1e9ea849891127400c9b6377532aa247a20fed12c301e
MD5 ecf958960abfa0002c40839be01c2fd9
BLAKE2b-256 9e4d105351a19516d7fe9374a4a4ca2060a4d72c60e486a868cf53767171740b

See more details on using hashes here.

File details

Details for the file afri_auth_sms-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: afri_auth_sms-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for afri_auth_sms-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 425a773b046f41270b4d6edc95ef9fd2cdbf9d89238ee93e6cde5c64e1dc9dde
MD5 163ae45d00dd3941c73e6bd0ad07675b
BLAKE2b-256 8706fb419a246fecf639d4b0e9d6ccfd8de7830e65b45bde09822dd1c7fc058f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page