JWT Signature Middleware is a pure ASGI Middleware that can be used with AGSI frameworks like FastAPI, Starlette and Sanic.
pip install jwt-signature-validator
from fastapi import FastAPI
from jwt_signature_validator import EncodedPayloadSignatureMiddleware
from pydantic import BaseModel
app = FastAPI()
app.add_middleware(
EncodedPayloadSignatureMiddleware,
jwt_secret="hello",
jwt_algorithms=["HS256"],
protect_hosts=["*"]
)
class Model(BaseModel):
text: str
@app.post("/")
def check(req: Model):
return req
This project is licensed under the terms of the MIT license.