Metadata-Version: 2.4
Name: afri-auth-sms
Version: 0.1.1
Summary: Plug and play OTP authentication for African telecom providers
Author: AdamKatani
License: MIT
Project-URL: Homepage, https://github.com/AdamMashaka/africastalking-kit-sms
Project-URL: Repository, https://github.com/AdamMashaka/africastalking-kit-sms
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: fastapi
Requires-Dist: uvicorn
Requires-Dist: redis
Requires-Dist: africastalking
Requires-Dist: python-dotenv
Requires-Dist: typer

# 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:

<!-- * Twilio
* Infobip
* Hubtel
* Termii -->
* WhatsApp OTP

---

# 📦 Installation

```bash id="69kbbi"
pip install afri-auth-sms
```

---

# 🚀 Quick Start

## 1. Initialize Afriauth

```python id="p4n0dd"
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

```python id="7s4i1q"
await auth.send_otp("+255694021848")
```

---

# ✅ Verify OTP

```python id="6m8p3d"
is_valid = await auth.verify_otp(
    phone="+255694021848",
    code="123456"
)

print(is_valid)
```

---

# ⚡ FastAPI Example

```python id="fvs1d1"
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

```python id="z0rx48"
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:

```text id="qtk0gz"
5 minutes
```

Custom configuration:

```python id="z8u6q9"
auth = AfriAuth(
    otp_expiry=300
)
```

---

# 🚦 Rate Limiting

Example:

```python id="9h3pzb"
auth = AfriAuth(
    max_requests_per_minute=3
)
```

---

# 🧠 Custom SMS Templates

```python id="f0xnnr"
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

```bash id="jlwm55"
afriauth init
```

Generate:

```text id="s06s3z"
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

```bash
pip install afri-auth-sms

```
# Project structure 

tree -L 3
