FastAPI Auth Middleware for Clerk (https://clerk.com)
Project description
FastAPI Clerk Auth Middleware
FastAPI Auth Middleware for Clerk
Easily setup authentication on your API routes using your Clerk JWKS endpoint.
Install
pip install fastapi-clerk-auth
Basic Usage
from fastapi import FastAPI, Depends
from fastapi_clerk_auth import ClerkConfig, ClerkHTTPBearer, HTTPAuthorizationCredentials
from fastapi.responses import JSONResponse
from fastapi.encoders import jsonable_encoder
app = FastAPI()
clerk_config = ClerkConfig(jwks_url="https://example.com/.well-known/jwks.json") # Use your Clerk JWKS endpoint
clerk_auth_guard = ClerkHTTPBearer(config=clerk_config)
@app.get("/")
async def read_root(credentials: HTTPAuthorizationCredentials | None = Depends(clerk_auth_guard)):
return JSONResponse(content=jsonable_encoder(credentials))
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
Built Distribution
Close
Hashes for fastapi_clerk_auth-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f03acd148dadc0608231c9f33addc9649fa145c6c1f9b91d174c73f7e45a2132 |
|
MD5 | 2a4062dc3667602989aeb5a8dfa276b8 |
|
BLAKE2b-256 | 0279d5fa8f7a867ec64b95027845c56219dadc4f69297c07232d22619624e872 |