Skip to content

Kubenew/fastapi-auth-kit

Repository files navigation

fastapi-authz-lite

PyPI Version Python Versions License: MIT Tests Downloads

fastapi-authz-lite provides plug-and-play authentication for FastAPI.

Features (v0.1.0)

  • JWT access token creation + verification
  • Password hashing (bcrypt)
  • FastAPI dependency: require_user()

Refresh tokens + OAuth planned for v0.2+.

Install

pip install fastapi-auth-kit

Quick example

from fastapi import FastAPI, Depends
from fastapi_auth_kit import AuthKit, AuthConfig

app = FastAPI()

auth = AuthKit(AuthConfig(secret_key="supersecret"))

@app.post("/login")
def login(username: str):
    token = auth.create_access_token({"sub": username})
    return {"access_token": token}

@app.get("/me")
def me(user=Depends(auth.require_user())):
    return user

License

MIT

Packages

 
 
 

Contributors

Languages