fastapi-key-auth

FastAPI API key authorizer

MIT License

Downloads
2.4K
Stars
37
Committers
6

Bot releases are visible (Hide)

fastapi-key-auth - [v0.6.0]: Add dependency authorizer

Published by iwpnd over 3 years ago

As Dependency

from fastapi import FastAPI, Depends
from fastapi_key_auth import AuthorizerDependency

authorizer = AuthorizerDependency(key_pattern="API_KEY_")

# either globally or in a router
app = FastAPI(dependencies=[Depends(authorizer)])
fastapi-key-auth - [0.5.0]: allow regex in public_path

Published by iwpnd over 3 years ago

  • allow regex match for public_path
from fastapi Import FastAPI
from fastapi_key_path import AuthorizerMiddleware

app = FastAPI()
app.add_middleware(AuthorizerMiddleware, public_paths=["/ping", "^/public"])
fastapi-key-auth - [v0.4.1]: fix public_path validation

Published by iwpnd over 3 years ago

  • fix an error in public_paths validation
fastapi-key-auth - [v0.4.0]: add option to add public routes

Published by iwpnd over 3 years ago

exclude path from x-api-key requirement.

from fastapi import FastAPI
from fastap_key_auth import AuthorizerMiddleware

app = FastAPI()

app.add_middleware(AuthorizerMiddleware, public_paths=["/health"])
fastapi-key-auth - Initial release :tada:

Published by iwpnd over 3 years ago

Secure your FastAPI with a middleware validating x-api-key in the header of incoming requests. Is the x-api-key present in your applications environment they will be authorized, else not. 🤩

Example:

from fastapi import FastAPI
from fastapi_key_auth import AuthorizerMiddleware

app = FastAPI()
app.add_middleware(AuthorizerMiddleware)
Package Rankings
Top 10.44% on Pypi.org
Related Projects