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: a security-first authority and delegation system for AI agents.

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.6rc2.tar.gz (8.2 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.6rc2-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: caracalai_asgi-0.1.6rc2.tar.gz
  • Upload date:
  • Size: 8.2 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.6rc2.tar.gz
Algorithm Hash digest
SHA256 2361c64ee9631da75f9df16d8ff56d3fd6d3aff91dcec84644663400134e55a2
MD5 f6d9b1725c700ad41a088a8e38b9037e
BLAKE2b-256 18454247690ea9e394a9b100575f420e97dede2351b5fe5cb1bf0c29c76c73ea

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for caracalai_asgi-0.1.6rc2-py3-none-any.whl
Algorithm Hash digest
SHA256 4f0003d46eef85afdf55d4da22dec18b970384dc8b58a24226b94395f3cab299
MD5 3237e63acc274b6a65c68cb1ac17c8fe
BLAKE2b-256 95d466da8ea6e6fc7aedcae183159c515ee83fddca297e35618765846277104d

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