Skip to content

aaryaa135/AuthForge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

38 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ” AuthForge

Production-ready Authentication & Authorization Platform built with FastAPI, PostgreSQL, Redis & Docker.

Python FastAPI PostgreSQL Redis Docker Pytest CI


πŸ“– Overview

AuthForge is a modular authentication and authorization platform designed with production-ready architecture and security best practices.

It provides secure user authentication, role-based authorization, JWT access & refresh tokens, Redis-powered token blacklisting, rate limiting, email verification, password reset, audit logging, automated testing, and CI/CD integration.

The project follows a clean modular architecture making it reusable across multiple applications.


✨ Features

Authentication

  • User Registration
  • Secure Login
  • JWT Access Tokens
  • Refresh Token Rotation
  • Logout
  • Session Management

Authorization

  • Role-Based Access Control (RBAC)
  • Admin/User Roles
  • Protected Routes

Security

  • Password Hashing (bcrypt)
  • Email Verification
  • Password Reset
  • Redis Token Blacklisting
  • Login Rate Limiting
  • Secure JWT Validation

Performance

  • Redis User Caching
  • Optimized Database Queries

Monitoring

  • Audit Logging
  • Request Tracking
  • Security Event Logging

DevOps

  • Docker Support
  • GitHub Actions CI
  • Automated Testing
  • Ruff
  • Black

πŸ— Architecture

                Client
                   β”‚
                   β–Ό
             FastAPI Server
                   β”‚
        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β”‚                     β”‚
 Authentication           Authorization
        β”‚                     β”‚
        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                   β”‚
              Auth Service
                   β”‚
      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
      β”‚            β”‚             β”‚
 PostgreSQL      Redis      Email Provider
      β”‚            β”‚
      β–Ό            β–Ό
 Persistent     Cache &
 Storage      Blacklisting

πŸ›  Tech Stack

Backend

  • FastAPI
  • SQLAlchemy
  • PostgreSQL
  • Redis
  • Pydantic v2

Authentication

  • JWT
  • OAuth2 Password Flow
  • RBAC
  • Refresh Token Rotation

Security

  • bcrypt
  • Email Verification
  • Password Reset
  • Rate Limiting

DevOps

  • Docker
  • GitHub Actions
  • Pytest
  • Ruff
  • Black

πŸ“‚ Project Structure

app/
β”‚
β”œβ”€β”€ cache/
β”œβ”€β”€ core/
β”œβ”€β”€ db/
β”œβ”€β”€ modules/
β”‚   β”œβ”€β”€ auth/
β”‚   β”œβ”€β”€ users/
β”‚   β”œβ”€β”€ roles/
β”‚   β”œβ”€β”€ audit/
β”‚   └── ...
β”‚
β”œβ”€β”€ providers/
β”œβ”€β”€ shared/
β”‚
tests/
alembic/

πŸ”‘ Authentication Flow

Register
    β”‚
    β–Ό
Email Verification
    β”‚
    β–Ό
Login
    β”‚
    β–Ό
Access Token
Refresh Token
    β”‚
    β–Ό
Protected APIs
    β”‚
    β–Ό
Refresh Token Rotation
    β”‚
    β–Ό
Logout
    β”‚
    β–Ό
JWT Blacklisted

πŸš€ Getting Started

Clone

git clone https://github.com/YOUR_USERNAME/AuthForge.git

cd AuthForge

Virtual Environment

python -m venv .venv

Windows

.venv\Scripts\activate

Linux

source .venv/bin/activate

Install Dependencies

pip install -r requirements.txt

Configure Environment

Create

.env
DATABASE_URL=
JWT_SECRET_KEY=
JWT_ALGORITHM=
REDIS_URL=
SMTP_USERNAME=
SMTP_PASSWORD=

Run Migrations

alembic upgrade head

Run Server

uvicorn app.main:app --reload

Swagger

http://localhost:8000/docs

🐳 Docker

Start Redis

docker run -d \
-p 6379:6379 \
--name authforge-redis \
redis:7

Verify

docker exec -it authforge-redis redis-cli
PING

PONG

πŸ§ͺ Running Tests

pytest

Current Status

13+ Tests Passing

πŸ“¬ API Endpoints

Authentication

Method Endpoint
POST /api/v1/auth/register
POST /api/v1/auth/login
POST /api/v1/auth/logout
POST /api/v1/auth/refresh
GET /api/v1/auth/me
POST /api/v1/auth/change-password
POST /api/v1/auth/forgot-password
POST /api/v1/auth/reset-password
GET /api/v1/auth/verify-email

πŸ”’ Security Features

βœ… Password Hashing

βœ… JWT Authentication

βœ… Refresh Token Rotation

βœ… Redis Token Blacklisting

βœ… Login Rate Limiting

βœ… RBAC

βœ… Email Verification

βœ… Password Reset

βœ… Audit Logging


πŸ“ˆ CI/CD

Every push automatically runs:

  • Ruff
  • Black
  • Pytest

via GitHub Actions.


πŸ—Ί Roadmap

  • Authentication
  • RBAC
  • Email Verification
  • Password Reset
  • Refresh Tokens
  • JWT Blacklisting
  • Redis Cache
  • Rate Limiting
  • Audit Logging
  • Session Management
  • Admin Dashboard APIs
  • Frontend Dashboard
  • Deployment

🀝 Contributing

Contributions are welcome.

Please open an issue before submitting large changes.


πŸ“„ License

MIT License

About

Production-ready authentication platform featuring JWT, RBAC, Redis caching, token blacklisting, email verification, password reset, audit logging, rate limiting, Docker, and CI/CD.

Topics

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors

Languages