← All Projects
01 · Project

AuthShield

Production-ready standalone authentication microservice with JWT rotation, OAuth 2.0, 2FA, RBAC, and session management - designed as a plug-and-play auth system for scalable applications - deploy once, plug into any project.

FastAPIPostgreSQLRedisDockerSQLAlchemy
↗ GitHub▶ Live Demo
Overview

Authentication is rebuilt in almost every project — login, roles, OAuth, sessions — costing weeks and often introducing subtle security flaws. AuthShield solves this by providing a single, production-grade authentication service that can be integrated into any application via APIs, eliminating the need to rebuild auth from scratch.

Built with FastAPI, PostgreSQL, and Redis, the system follows a clean layered architecture (API → Service → Repository → Infrastructure). It uses short-lived JWT access tokens and rotating refresh tokens with reuse detection, ensuring both stateless performance and strong security guarantees.

Redis powers token blacklisting, rate limiting, OAuth state validation, and temporary auth flows with sub-millisecond lookups. The system is fully containerized and ships with 48 integration tests running against real infrastructure, ensuring production reliability.

A key design highlight is the refresh token family model — any reuse of a compromised token instantly revokes the entire session chain, preventing silent account takeover and forcing re-authentication.

48Integration tests (real infra)
<10msToken validation latency
2FATOTP with reuse detection
0Auth logic in client apps
Tech Stack

TOOLS &
TECHNOLOGIES.

TECH.01
FastAPI
TECH.02
PostgreSQL
TECH.03
Redis
TECH.04
Docker
TECH.05
SQLAlchemy
Key Highlights

WHAT MAKES IT
STAND OUT.

48Integration tests on real infra
<10msToken validation with Redis blacklist
7Redis key namespaces for auth state
2OAuth providers with CSRF protection
0Auth code needed in downstream apps
40Line auth.py for any new project
Challenges & Solutions

WHAT WAS HARD.
HOW I SOLVED IT.

Critical Challenge

JWT logout does not invalidate active tokens due to stateless design.

Engineered Solution

Used Redis blacklist with jti + TTL for O(1) validation, enabling immediate token revocation without breaking stateless flow.

Critical Challenge

Refresh token theft enables undetected session hijacking.

Engineered Solution

Introduced token family tracking with reuse detection, triggering full session invalidation on suspicious reuse.

Critical Challenge

OAuth flows are exposed to CSRF and replay attacks.

Engineered Solution

Secured callbacks with Redis-backed state tokens (TTL + single-use), ensuring strict request validation.

Core Architecture

HOW IT'S
ALL WIRED UP.