Skip to main content

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 like app.add_middleware(JWTMiddleware) to secure your routes with JWT validation.
  • Fastapi Router dependency: Integrate the provided jwk_validator function into your FastAPI router like app.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:

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fastapi-jwk-auth-0.0.3.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

fastapi_jwk_auth-0.0.3-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file fastapi-jwk-auth-0.0.3.tar.gz.

File metadata

  • Download URL: fastapi-jwk-auth-0.0.3.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.0

File hashes

Hashes for fastapi-jwk-auth-0.0.3.tar.gz
Algorithm Hash digest
SHA256 fe72b024d09925b1ba9f0236cdca372f6c55395ba41b5e8d230a81bfebf25e0b
MD5 f511b6fcda281fc7df2777dfab665f4e
BLAKE2b-256 8b3e126ad3024ba1f634746f32c79edd313faabb361a063e79af9bb18c53f9ef

See more details on using hashes here.

File details

Details for the file fastapi_jwk_auth-0.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for fastapi_jwk_auth-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 3d01c984447fb5ae6f2533c44700c1cbe681e3d3c147cc162e302ea98baaf07f
MD5 e732fb46aa451c755d9991eb36d2ddf1
BLAKE2b-256 4cfd6a5b7e0a0bcc9969398b02d70d3c198a37b398f14a02d67fff7652d36f83

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page