fastapi-authz-lite provides plug-and-play authentication for FastAPI.
- JWT access token creation + verification
- Password hashing (bcrypt)
- FastAPI dependency:
require_user()
Refresh tokens + OAuth planned for v0.2+.
pip install fastapi-auth-kitfrom 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 userMIT