Awesome Open Source
Awesome Open Source



Ready-to-use and customizable Authentications and Oauth2 management for FastAPI

Test Build Docs Publish Pypi codecov Downloads framework

Source Code:


Add a Fully registration and authentication or authorization system to your FastAPI project. AuthX is designed to be as customizable and adaptable as possible.


  • [x] Support Python 3.8+.
  • [x] Extensible base user model.
  • [x] Ready-to-use register, login, reset password and verify e-mail routes.
  • [x] Ready-to-use Social login and Oauth2 routes.
    • [x] Full Configuration and customization.
    • [x] Ready-to-use social OAuth2 login flow.
  • [x] Middleware Support for Oauth2 using Authlib and Starlette.
  • [x] Dependency callable to inject current user in route.
  • [x] Pluggable password validation
    • [x] Using Captcha Service.
    • [x] Implements the HMAC algorithm And Hashlib library.
  • [x] Using Email Service. (SMTP)
  • [x] Extensible Error Handling
  • [x] High level API to manage users, roles and permissions
  • [x] Using Redis as a session store & cache.
  • [x] Support HTTPCache.
  • [x] Customizable database backend:
  • [x] Multiple customizable authentication backend:
    • [x] JWT authentication backend included
    • [x] Cookie authentication backend included
  • [x] Full OpenAPI schema support, even with several authentication backend.
  • [x] Provide a Docstring for each class and function.
  • [x] Support Sessions and Pre-built CRUD functions and Instance to launch Redis.
  • [x] Support SocketIO.
  • [x] Support Middleware of pyinstrument to check your service performance.

Note: Check Release Notes.

Note: Check Examples.

Project using

from fastapi import APIRouter, Depends, FastAPI
from authx import Authentication, User, BaseDBBackend, RedisBackend

app = FastAPI()
auth = Authentication(database_backend=BaseDBBackend())
router = APIRouter()

# Set up Pre-configured Routes
app.include_router(auth.auth_router, prefix="/api/users")
app.include_router(auth.social_router, prefix="/auth")
app.include_router(auth.password_router, prefix="/api/users")
app.include_router(auth.admin_router, prefix="/api/users")
app.include_router(auth.search_router, prefix="/api/users")

# Set Redis Cache

# Set Anonymous User
def anonym_test(user: User = Depends(auth.get_user)):

# Set Authenticated User
def user_test(user: User = Depends(auth.get_authenticated_user)):

# Set Admin User
@router.get("/admin", dependencies=[Depends(auth.admin_required)])
def admin_test():

Contributors and sponsors

All Contributors

Thanks goes to these wonderful people (emoji key):

Yasser Tahiri


Ismail Ghallou

talentuno LLC

Cactus LLC


Stphane Raimbault


Yogesh Upadhyay

This project follows the all-contributors specification. Contributions of any kind welcome!



This project is licensed under the terms of the MIT License.

Alternatives To Authx
Select To Compare

Alternative Project Comparisons
Related Awesome Lists
Top Programming Languages
Top Projects

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
Python (806,773
Python3 (806,763
Databases (92,939
Mongodb (29,765
Auth (26,842
Authentication (26,842
Oauth2 (14,217
Jwt (9,805
Sqlalchemy (3,017
Fastapi (1,274
Sessionstorage (543
Redis Cache (317
Pydantic (189
Starlette (143
Authentication Middleware (68