Skip to content

byte-dev01/fastapi-users

ย 
ย 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

812 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

FastAPI Users

/////// Personal Notes: Fast API Users is a Python library that provides ready-to-use user authentication and management functionality for FastAPI applications. Think of it as a toolkit that handles all the common user related features you'd typically need to build yourself.

What it does: The library gives you pre-built solutions for standard authentication features like user registration, login/logout, password reset, and email verification. It also supports social login through OAuth2 (like "Sign in with Google" or "Sign in with GitHub").

Key Features: Multiple authentication methods (JWT tokens, session cookies, or database-based auth) Flexible database support (works with SQLAlchemy for SQL databases or MongoDB) Built-in security features like password validation Easy integration with FastAPI's dependency injection system Full OpenAPI/Swagger documentation support

Authentication Routes It automatically creates API endpoints for you, such as:

POST /auth/register - Create new user accounts POST /auth/login - Log users in and get an authentication token POST /auth/logout - End user sessions POST /auth/forgot-password - Request password reset POST /auth/reset-password - Actually reset the password POST /auth/verify - Confirm email addresses

Authentication Strategies You can choose how users prove their identity:

JWT (JSON Web Tokens): Stateless tokens that contain user information, commonly used for APIs and mobile apps Cookie-based: Traditional web session authentication using browser cookies Database tokens: Tokens stored in your database for more control Redis: Fast, in-memory token storage for high-performance needs

Authentication Strategies You can choose how users prove their identity:

JWT (JSON Web Tokens): Stateless tokens that contain user information, commonly used for APIs and mobile apps Cookie-based: Traditional web session authentication using browser cookies Database tokens: Tokens stored in your database for more control Redis: Fast, in-memory token storage for high-performance needs

Database Flexibility It works with different database systems through "adapters":

SQLAlchemy: For traditional SQL databases like PostgreSQL, MySQL, or SQLite Beanie: For MongoDB (a NoSQL database)

OAuth2 / Social Login The library also supports "Sign in with Google/GitHub/Facebook" type flows. It handles the complex OAuth2 protocol for you, including redirecting users to the provider, receiving the authentication callback, and creating or linking user accounts.

Security Built-In Important security features are handled automatically:

Passwords are properly hashed (never stored in plain text) Tokens can have expiration times Email verification to prevent fake signups Password strength validation (you can customize the rules)

Instead of spending time writing all the authentication code from scratchโ€”handling password hashing, token generation, user verification emails, etc.โ€”you can use this library to get a complete, secure user management system up and running quickly in your FastAPI project.

FastAPI Users

Ready-to-use and customizable users management for FastAPI

Note

This project is now in maintenance mode. While we'll continue to provide security updates and dependency maintenance, no new features will be added. We encourage you to explore the project and use it as-is, knowing it will remain stable and secure.

We're currently working on a new Python authentication toolkit that will ultimately supersede FastAPI Users. Stay tuned for updates!

build codecov PyPI version Downloads

All Contributors


Documentation: https://fastapi-users.github.io/fastapi-users/

Source Code: https://github.com/fastapi-users/fastapi-users


Add quickly a registration and authentication system to your FastAPI project. FastAPI Users is designed to be as customizable and adaptable as possible.

Features

  • Extensible base user model
  • Ready-to-use register, login, reset password and verify e-mail routes
  • Ready-to-use social OAuth2 login flow
  • Dependency callables to inject current user in route
  • Pluggable password validation
  • Customizable database backend
  • Multiple customizable authentication backends
    • Transports: Authorization header, Cookie
    • Strategies: JWT, Database, Redis
  • Full OpenAPI schema support, even with several authentication backends

Contributors and sponsors โœจโ˜•๏ธ

Thanks goes to these wonderful people (emoji key):

Franรงois Voron
Franรงois Voron

๐Ÿšง
Paolo Dina
Paolo Dina

๐Ÿ’ต ๐Ÿ’ป
Dmytro Ohorodnik
Dmytro Ohorodnik

๐Ÿ›
Matthew D. Scholefield
Matthew D. Scholefield

๐Ÿ› ๐Ÿ’ป
roywes
roywes

๐Ÿ› ๐Ÿ’ป
Satwik Kansal
Satwik Kansal

๐Ÿ“–
Edd Salkield
Edd Salkield

๐Ÿ’ป ๐Ÿ“–
mark-todd
mark-todd

๐Ÿ’ป ๐Ÿ“–
lill74
lill74

๐Ÿ› ๐Ÿ’ป ๐Ÿ“–
SelfhostedPro
SelfhostedPro

๐Ÿ›ก๏ธ ๐Ÿ’ป
Oskar Gmerek
Oskar Gmerek

๐Ÿ“–
Martin Collado
Martin Collado

๐Ÿ› ๐Ÿ’ป
Eric Lopes
Eric Lopes

๐Ÿ“– ๐Ÿ›ก๏ธ
Beau Breon
Beau Breon

๐Ÿ’ป
Niyas Mohammed
Niyas Mohammed

๐Ÿ“–
prostomarkeloff
prostomarkeloff

๐Ÿ“– ๐Ÿ’ป
Marius Mรฉzerette
Marius Mรฉzerette

๐Ÿ› ๐Ÿค”
Nickolas Grigoriadis
Nickolas Grigoriadis

๐Ÿ›
Open Data Coder
Open Data Coder

๐Ÿค”
Mohammed Alshehri
Mohammed Alshehri

๐Ÿค”
Tyler Renelle
Tyler Renelle

๐Ÿค”
collerek
collerek

๐Ÿ’ป
Robert Bracco
Robert Bracco

๐Ÿ’ต
Augusto Herrmann
Augusto Herrmann

๐Ÿ“–
Smithybrewer
Smithybrewer

๐Ÿ›
silllli
silllli

๐Ÿ“–
alexferrari88
alexferrari88

๐Ÿ’ต
sandalwoodbox
sandalwoodbox

๐Ÿ› ๐Ÿ“–
Vlad Hoi
Vlad Hoi

๐Ÿ“–
Joe Nudell
Joe Nudell

๐Ÿ›
Ben
Ben

๐Ÿ’ป
BoYanZh
BoYanZh

๐Ÿ“–
David Brochart
David Brochart

๐Ÿ“– ๐Ÿ’ป
Daan Beverdam
Daan Beverdam

๐Ÿ’ป
Stรฉphane Raimbault
Stรฉphane Raimbault

โš ๏ธ ๐Ÿ›
Sondre Lillebรธ Gundersen
Sondre Lillebรธ Gundersen

๐Ÿ“–
Maxim
Maxim

๐Ÿ“– ๐Ÿ›
scottdavort
scottdavort

๐Ÿ’ต
John Dukewich
John Dukewich

๐Ÿ“–
Yasser Tahiri
Yasser Tahiri

๐Ÿ’ป
Brandon H. Goding
Brandon H. Goding

๐Ÿ’ป ๐Ÿ“–
PovilasK
PovilasK

๐Ÿ’ป
Just van den Broecke
Just van den Broecke

๐Ÿ’ต
jakemanger
jakemanger

๐Ÿ› ๐Ÿ’ป
Ikko Ashimine
Ikko Ashimine

๐Ÿ’ป
Matyรกลก Richter
Matyรกลก Richter

๐Ÿ’ป
Hazedd
Hazedd

๐Ÿ› ๐Ÿ“–
Luis Roel
Luis Roel

๐Ÿ’ต
Alexandr Makurin
Alexandr Makurin

๐Ÿ’ป ๐Ÿ›
Leon Thurner
Leon Thurner

๐Ÿ“–
Goran Mekiฤ‡
Goran Mekiฤ‡

๐Ÿ“ฆ
Gaganpreet
Gaganpreet

๐Ÿ’ป
Joe Taylor
Joe Taylor

๐Ÿ’ป
Richard Friberg
Richard Friberg

๐Ÿ›
Kenton Parton
Kenton Parton

๐Ÿ’ต
Adrian Cioล‚ek
Adrian Cioล‚ek

๐Ÿ›
โญ•Alexander Rymdeko-Harvey
โญ•Alexander Rymdeko-Harvey

๐Ÿ“–
schwannden
schwannden

๐Ÿšง ๐Ÿ’ป
Jimmy Angel Pรฉrez Dรญaz
Jimmy Angel Pรฉrez Dรญaz

๐Ÿ›ก๏ธ
Austin Orr
Austin Orr

๐Ÿšง
Carlo Eugster
Carlo Eugster

๐Ÿ›ก๏ธ
Vittorio Zamboni
Vittorio Zamboni

๐Ÿ’ป
Andrey
Andrey

๐Ÿ“–
Can H. Tartanoglu
Can H. Tartanoglu

๐Ÿ›
Filipe Nascimento
Filipe Nascimento

๐Ÿ›ก๏ธ
dudulu
dudulu

๐Ÿ’ต ๐Ÿ› ๐Ÿ’ฌ
Toni Alatalo
Toni Alatalo

๐Ÿ’ป ๐Ÿ“–
Bรถrge Kiss
Bรถrge Kiss

๐Ÿ“–
Guilherme Caminha
Guilherme Caminha

๐Ÿ“–
Tรฉva KRIEF
Tรฉva KRIEF

๐Ÿ’ป
Essa Alshammri
Essa Alshammri

๐Ÿ“–
0xJan
0xJan

๐Ÿ›
Justin Thomas
Justin Thomas

๐Ÿ’ป
Adam Israel
Adam Israel

๐Ÿ’ป
Nerixjk
Nerixjk

๐Ÿ› ๐Ÿ’ป
Mike Fotinakis
Mike Fotinakis

๐Ÿ’ป ๐Ÿ›
lifengmds
lifengmds

๐Ÿ’ต
raindata5
raindata5

๐Ÿ“–
Mark Donnelly
Mark Donnelly

๐Ÿ“–
Alexander Zinov
Alexander Zinov

๐Ÿ’ป
nimaxin
nimaxin

๐Ÿ“–
Muhammad Daffa Dinaya
Muhammad Daffa Dinaya

๐Ÿ›
Joschka Thurner
Joschka Thurner

๐Ÿ›

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

Development

Setup environment

We use Hatch to manage the development environment and production build. Ensure it's installed on your system.

Run unit tests

You can run all the tests with:

hatch run test

Format the code

Execute the following command to apply linting and check typing:

hatch run lint

Serve the documentation

You can serve the documentation locally with the following command:

hatch run docs

The documentation will be available on http://localhost:8000.

License

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

About

Ready-to-use and customizable users management for FastAPI

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 99.9%
  • HTML 0.1%