GithubHelp home page GithubHelp logo

lynxye / authx Goto Github PK

View Code? Open in Web Editor NEW

This project forked from yezz123/authx

0.0 0.0 0.0 1.52 MB

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

Home Page: https://authx.yezz.me/

License: MIT License

Shell 1.96% Python 98.04%

authx's Introduction

AuthenticationX 💫

AuthX

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

lint Package version Test


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

Documentation: https://authx.yezz.me/


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

This branch relates to development of authx V1 which is not yet ready for production use.

If you're a Authx user, you probably want either Authx V0.9 Documentation or, 0.X.X-fix git branch.

Features 🔧

  • Support Python 3.8+.
  • Multiple customizable authentication backend:
    • JWT authentication backend included
      • JWT encoding/decoding for application authentication
      • Automatic detection of JWTs in requests:
        • JWTs in headers
        • JWTs in cookies
        • JWTs in query parameters
        • JWTs in request bodies
    • Cookie authentication backend included
  • middleware for authentication and authorization through JWT.
  • Extensible Error Handling System.
  • Using Redis as a session store & cache.
  • Support HTTPCache.
  • Support Sessions and Pre-built CRUD functions and Instance to launch Redis.
  • Support Middleware of pyinstrument to check your service performance.
  • Support Middleware for collecting and exposing Prometheus metrics.

Note: Check Release Notes.

Project using 🚀

Here is a simple way to kickstart your project with AuthX:

from fastapi import FastAPI, Depends, HTTPException
from authx import AuthX, AuthXConfig, RequestToken

app = FastAPI()

config = AuthXConfig(
     JWT_ALGORITHM = "HS256",
     JWT_SECRET_KEY = "SECRET_KEY",
     JWT_TOKEN_LOCATION = ["headers"],
)

auth = AuthX(config=config)
auth.handle_errors(app)

@app.get('/login')
def login(username: str, password: str):
     if username == "xyz" and password == "xyz":
          token = auth.create_access_token(uid=username)
          return {"access_token": token}
     raise HTTPException(401, detail={"message": "Invalid credentials"})

@app.get("/protected", dependencies=[Depends(auth.get_token_from_request)])
def get_protected(token: RequestToken = Depends()):
     try:
          auth.verify_token(token=token)
          return {"message": "Hello world !"}
     except Exception as e:
          raise HTTPException(401, detail={"message": str(e)}) from e

Contributors and sponsors ✨☕️

All Contributors

Thanks goes to these wonderful people (emoji key):

Yasser Tahiri
Yasser Tahiri

💻 📖 🚧 🚇
Abderrahim SOUBAI-ELIDRISI
Abderrahim SOUBAI-ELIDRISI

👀 📖
Ismail Ghallou
Ismail Ghallou

💻 🛡️
talentuno LLC
talentuno LLC

💵
Cactus LLC
Cactus LLC

💵
MojixCoder
MojixCoder

💻 🐛
Stéphane Raimbault
Stéphane Raimbault

💻 🔌
theoohoho
theoohoho

📖
Yogesh Upadhyay
Yogesh Upadhyay

🐛
Roman
Roman

🐛
Alvaro Lopez Ortega
Alvaro Lopez Ortega

📖

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

Links 🚧

License 📝

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

authx's People

Contributors

allcontributors[bot] avatar alobbs avatar dependabot[bot] avatar fossabot avatar iamromandev avatar mojixcoder avatar pyup-bot avatar smakosh avatar soub4i avatar theoohoho avatar yezz123 avatar yogeshupdhyay 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.