Skip to content

iudeen/ASGIJWTSignatureValidatorMiddleware

Repository files navigation

JWT Signature Validator

Latest Commit
Package version

JWT Signature Middleware is a pure ASGI Middleware that can be used with AGSI frameworks like FastAPI, Starlette and Sanic.

Installation

pip install jwt-signature-validator

Usage

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

License

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