Code Monkey home page Code Monkey logo

authx's Introduction

AuthenticationX 💫

authx

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

Test Build Docs Pypi codecov Downloads framework


Source Code: https://github.com/yezz123/AuthX

Documentation: https://authx.yezz.codes/


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

Features 🔧

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

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
auth.set_cache(RedisBackend)

# Set Anonymous User
@router.get("/anonym")
def anonym_test(user: User = Depends(auth.get_user)):
    pass


# Set Authenticated User
@router.get("/user")
def user_test(user: User = Depends(auth.get_authenticated_user)):
    pass


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

Development 🚧

Setup environment 📦

You should create a virtual environment and activate it:

python -m venv venv/
source venv/bin/activate

And then install the development dependencies:

pip install -r requirements.dev.txt

Run tests 🌝

I use Pytest to run the tests, you can run this by using a shortcut command in the Makefile:

make test

Format the code 🍂

Execute the following command to apply pre-commit formatting:

make lint

Contributors and sponsors ✨☕️

All Contributors

Thanks goes to these wonderful people (emoji key):


Yasser Tahiri

💻 📖 🚧 🚇

Abderrahim SOUBAI-ELIDRISI

👀 📖

Ismail Ghallou

💻 🛡️

talentuno LLC

💵

Cactus LLC

💵

MojixCoder

💻 🐛

Stéphane Raimbault

💻 🔌

theoohoho

📖

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

License 📝

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

authx's People

Contributors

yezz123 avatar pyup-bot avatar allcontributors[bot] avatar dependabot[bot] avatar soub4i avatar smakosh avatar mojixcoder avatar theoohoho avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.