Skip to main content

ASGI middleware for Caracal mandate verification (FastAPI, Starlette, Quart)

Project description

caracalai-asgi

ASGI middleware for Caracal mandate verification. Protects FastAPI, Starlette, Quart, and any other ASGI application with fail-closed verification of Caracal-issued mandates.

Part of Caracal: the identity and authorization layer for AI agents - short-lived, policy-approved authority instead of credentials.

Install

pip install caracalai-asgi

Use

from caracalai_asgi import CaracalASGIAuth
from caracalai_revocation import InMemoryRevocationStore
from fastapi import FastAPI

app = FastAPI()
app.add_middleware(
    CaracalASGIAuth,
    audience="resource://billing-api",
    revocations=InMemoryRevocationStore(),
    routes={"/payouts": {"required_scopes": ["billing:payout"], "require_delegation": True}},
    exclude=["/healthz"],
)

The issuer defaults to CARACAL_STS_URL and the zone to CARACAL_ZONE_ID. Verified claims are available as request.state.caracal.

Links

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

caracalai_asgi-0.1.6rc3.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

caracalai_asgi-0.1.6rc3-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file caracalai_asgi-0.1.6rc3.tar.gz.

File metadata

  • Download URL: caracalai_asgi-0.1.6rc3.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for caracalai_asgi-0.1.6rc3.tar.gz
Algorithm Hash digest
SHA256 eaacf5393691bf30716f7770837faa632ff6aaf64c5ded34f6810b91861335f4
MD5 d679113b01bc01ae6e08a94f6cf930be
BLAKE2b-256 3c51a5daee237afb4c5b1d6041847771b41e4b13ecfbce61737ad69732c8f882

See more details on using hashes here.

File details

Details for the file caracalai_asgi-0.1.6rc3-py3-none-any.whl.

File metadata

File hashes

Hashes for caracalai_asgi-0.1.6rc3-py3-none-any.whl
Algorithm Hash digest
SHA256 92c3dc78cfa3b1a04351d84a2ec163927d3ac4c2d5a107fd9c265dbaf24b6db7
MD5 5089fe5d5f70210b15c3ec2b8ff38648
BLAKE2b-256 f616332181a561e6a0713d0d650c0b28bf7eacde2bd3b522cfd4af8dcd67f121

See more details on using hashes here.

Supported by

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