• Stars
    star
    554
  • Rank 77,758 (Top 2 %)
  • Language
    Python
  • License
    MIT License
  • Created almost 3 years ago
  • Updated 10 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

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.

Authx V0.9.x

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.

More Repositories

1

DogeAPI

API with high performance to create a simple blog and Auth using OAuth2 ⛏
Python
120
star
2

ormdantic

Asynchronous ORM that uses pydantic models to represent database tables ✨
Python
119
star
3

fastapi-lazy

Lazy package to start your project using FastAPI✨
Python
99
star
4

SoIG

OSINT Tool gets a range of information from an Instagram account πŸ› 
Python
89
star
5

fastapi-class

provides a class-based View decorator to help reduce the amount of boilerplate necessary when developing related routes. βœ¨πŸš€
Python
75
star
6

FRDP

Boilerplate code for quick docker implementation of REST API with JWT Authentication using FastAPI, PostgreSQL and PgAdmin ⭐
Python
60
star
7

pyngo

Pydantic model support for Django & Django-Rest-Framework ✨
Python
58
star
8

My-Business

Business management tool featuring accounts, invoices, partners, projects, and server πŸ¦„
Python
44
star
9

Athena

Test your Security Skills, and Clean Code Development as a Pythonist, Hacker & Warrior πŸ₯·πŸ»
Python
43
star
10

fastapi-tag

Documented & Enhance the Metadata of your API ✨
Python
37
star
11

JeffQL

fastAPI Simple authentication & Login API using GraphQL and JWT πŸš€
Python
28
star
12

yezz.me

My personal website πŸš€
JavaScript
25
star
13

asgi-aws

Build API with ASGI in AWS Lambda with API Gateway HTTP API or REST API, or with Function URL ✨
Python
24
star
14

yezz123.github.io

My personal website πŸš€
JavaScript
23
star
15

CoveAPI

OpenAPI-based test coverage analysis tool that helps teams improve integration test coverage in CI/CD pipelines
Rust
18
star
16

VSCode-Sidebar-Themes

VSCode sidebar themes Website where you can copy & share your Sidebar Themes.
TypeScript
18
star
17

Blog

A Next.js, Tailwind CSS blogging Template. Used to Create my Blog πŸš€
JavaScript
17
star
18

Parser

Pure Python standard library JSON πŸ¦„
Python
12
star
19

pagidantic

Pagination using Pydantic. Easy to use, lightweight, and easy to integrate with existing projects πŸ’‘
Python
10
star
20

yezz123

My official Github Configuration πŸš€
10
star
21

yasgi

yasgi is a tiny ASGI framework ✨
Python
7
star
22

stripe-template

Template for integrating stripe into your FastAPI application πŸ’Έ
Python
5
star
23

pg-dummy

A simple Script Help to insert Some Dummy Data to Populate Database For Testing
Python
3
star
24

RustyServer

A simple and minimalistic HTTP server for Rust
Rust
3
star
25

pycontent-type

A Python library to access all Supported Content-Types/Media-Types
Python
2
star
26

pypi-python-template

Quickly creating a new Modern Python project and publishing it to PyPI ✨
Python
1
star
27

spotify-preview

a simple bootstrapped application to show my own playlists
TypeScript
1
star
28

pyregex

Python bindings for the Rust regex Crate ✨
1
star
29

AWSFlowUtils

Improve your data workflow with enhanced simplicity and robustness in handling common data tasks ✨
Python
1
star