Current collected state Current
Observed since 20 Oct, 22:28 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
Agentity middleware for FastAPI
FastAPI middleware for the Agentity Protocol.
Automatically verify Agentity-signed requests — extract agent identity, validate nonce and timestamp, check status via registry, and inject request.state.agent_did + request.state.agent_scopes.
pip install agentity-middleware-python
from fastapi import FastAPI, Request
from agentity_middleware_python import AgentityMiddleware
app = FastAPI()
# Add middleware (optional registry check)
app.add_middleware(
AgentityMiddleware,
registry_url="http://localhost:8000", # Optional: verify DID status
tolerance_seconds=300, # Default: 5 min
)
@app.get("/api/data")
async def get_data(request: Request):
# Verified agent info automatically injected
agent_did = request.state.agent_did # "did:agentity:agent:..."
agent_scopes = request.state.agent_scopes # ["stripe:payments:read", ...]
return {"agent": agent_did, "scopes": agent_scopes}
Agentity-Token, Agentity-Nonce, Agentity-Timestamp headersregistry_url is set, checks GET /did/{did}/status for active statusrequest.state.agent_did and request.state.agent_scopes400 (malformed), 401 (missing), or 403 (invalid/revoked) on failure| Status | Condition |
|---|---|
| 400 | Missing or malformed headers |
| 401 | Token not provided |
| 403 | Invalid signature, expired, revoked, or scope violation |
pip install -e .[dev]
pytest ../tests/
License: Apache 2.0
Download counts and popularity will appear here as the collector receives them.
| Version | Published | Direct dependencies | Open version |
|---|---|---|---|
| 0.1.1 | 17 May 2026 | 5 |
This describes our collected data; it is not a security assessment.
Observed since 20 Oct, 22:28 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:e78f1d57c2bf93f14abe0a56fe88e2301b8e8c1641d87300769a5576b82d8c9b