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

Uploaded Python 3

File details

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

File metadata

  • Download URL: caracalai_asgi-0.1.6rc1.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.6rc1.tar.gz
Algorithm Hash digest
SHA256 2c7a6fcd5687de7d746de0c02d12a9dee28e33cf5f38f7d5f505d5a59c5ceaba
MD5 33ebeb345d162931e282c7fbbb6d89cb
BLAKE2b-256 26a419e0a0a5df091db6e91603b5b6fd50fc2c7fc1757a729e910a65dc47226f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for caracalai_asgi-0.1.6rc1-py3-none-any.whl
Algorithm Hash digest
SHA256 c60b2d182823d99fd80c0eaf3ef1e423a5bb7b64dcb0024a32ddd9ed8245beaf
MD5 d81a87ef407020938100a43d6be35944
BLAKE2b-256 f6ed6c79c320a8428c1868308407e0bfc1bacf4691dcd102e2bc9378716ba602

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