No project description provided
Project description
Fastapi JWKS Auth(Validator)
Overview
FastAPI JWK Auth is a Python package designed to enhance FastAPI applications with easy and secure JSON Web Token (JWT) validation using JSON Web Key Sets (JWKS). It simplifies the integration of JWT-based authentication in your FastAPI project when JWKS URLs are employed for key retrieval.
Features
- JWKS-Based JWT Validation: Seamlessly validate JWTs using JWKS obtained from configured URLs.
- FastAPI Middleware Integration: Integrate the provided
JWTMiddleware
class into your FastAPI application middleware likeapp.add_middleware(JWTMiddleware)
to secure your routes with JWT validation. - Fastapi Router dependency: Integrate the provided
jwk_validator
function into your FastAPI router likeapp.include_router(auth_app.router, dependencies=[Depends(jwk_validator)])
to secure your product with JWT validation - Efficient JWK Handling: Retrieve and utilize JSON Web Key Sets efficiently in your FastAPI routes with the
fetch_jwks
function. - Exception Handling: Easily manage JWT validation exceptions using FastAPI's HTTPException.
Installation
Install the package using pip:
pip install fastapi-jwk-auth
Usage
FastAPI Middleware Integration
from fastapi import FastAPI, Depends
from fastapi_jwk_auth.jwks_auth import jwk_validator, JWKMiddleware
app = FastAPI()
# Include the JWT Middleware
app.add_middleware(JWTMiddleware)
FastAPI Route JWT Validation
from fastapi import FastAPI, Depends
from fastapi_jwk_auth.jwks_auth import jwk_validator, JWKMiddleware
app=FastAPI()
app.include_router(auth_app.router, dependencies=[Depends(jwk_validator)])
Configuration
Set the following environment variable to the JSON Web Key Set (JWKS) URI:
export JWK_HOST="https://your-identity-server"
Contributing
Feel free to open PR/Issues.
License
This project is licensed under the MIT License.
Contact
For questions or feedback, feel free to contact us at [omkardarves@gmail.com].
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file fastapi-jwk-auth-0.0.5.tar.gz
.
File metadata
- Download URL: fastapi-jwk-auth-0.0.5.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7b93881871aba7549c46140e1d791213e6c3c1cd2cbef1be76c2647cc2ddc9c1 |
|
MD5 | edc7656e660142b2c8f5a1046385bde4 |
|
BLAKE2b-256 | 4e832b05a8f750caf74a522275b92ac403eb609c2bdf7ebf1c6914313ff34db2 |
File details
Details for the file fastapi_jwk_auth-0.0.5-py3-none-any.whl
.
File metadata
- Download URL: fastapi_jwk_auth-0.0.5-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e05c733b486f71ee2f7826742e5a272affd10366d730355c388c1736cc5cb019 |
|
MD5 | cd42b94cbc4a45926e3318de275ee9fe |
|
BLAKE2b-256 | f625345c26052fd169b4ab5ddc549804d4b43b01c9ec03db2af7f668cbd67646 |