ubag (Python)
UBAG Web Layer — agent identity and routing at the web edge. FastAPI / Starlette middleware.
When an autonomous agent visits a website, UBAG verifies who it is and routes accordingly: humans to your normal site, credentialed agents to clean JSON-LD, unknown automation to a cryptographic challenge. Identity verification and site authorization are separate. Asymmetric by design — agent identity is an Ed25519 keypair; credentials are ES256 JWTs verifiable via JWKS, no shared secrets.
Early but real, pre-1.0, unaudited. See the full README and SECURITY.md.
Install
pip install "ubag[fastapi]"
Quick start
from fastapi import FastAPI
from ubag import UBAGMiddleware, generate_issuer_keypair
issuer_private, _ = generate_issuer_keypair() # EC P-256 (ES256)
trusted_agents = {"ubag:replace-with-an-approved-agent-id"}
app = FastAPI()
app.add_middleware(
UBAGMiddleware,
origin="https://yoursite.com",
issuer_key=issuer_private, # mints + verifies credentials
server_secret="a-separate-random-32+char-secret",
authorize_agent=lambda identity, request: identity["agent_id"] in trusted_agents,
# site_meta is OPTIONAL — Branch B auto-extracts structured data from your
# origin's HTML (JSON-LD/OpenGraph/meta). Pass site_meta only to override.
)
Your site now serves credentialed agents auto-extracted JSON-LD plus a labeled
Markdown content layer (no hand-written metadata), proxies humans to your origin,
challenges unknown automation, exposes /.well-known/ubag.json for discovery, and
serves its issuer key as JWKS at /.well-known/jwks.json. Credentials are
holder-of-key: agents attach a one-time request-bound proof-of-possession via
agent.headers(method, absolute_url).
A Node/Express SDK with an identical, cross-verifiable wire format is in the same repo. Full docs, a runnable demo, and the protocol details: https://github.com/mohameduk/Ubag_protocol
MIT licensed.
Release files for ubag 0.6.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ubag-0.6.0.tar.gz | 52.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ubag-0.6.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 97.5 kB
Release files / ubag-0.6.0.tar.gz
| Download URL | ubag-0.6.0.tar.gz |
|---|---|
| Size | 52.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2588e87b5969c418342d1f825843c8ff92a51d34fcee2a2af4b4042131608dde
|
|
BLAKE2b-256 checksum How to use checksums |
1e00eba997d8c169739cb2f329489ea73cec67ee0fe9f296ea7e62ec574bd4ad
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 24, 2026.
Transparency logRelease files / ubag-0.6.0-py3-none-any.whl
| Download URL | ubag-0.6.0-py3-none-any.whl |
|---|---|
| Size | 45.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a1fe53eac22303e1d2d9ca737cc6a2e8286a8962d4f7dbb540366847d20e1cd7
|
|
BLAKE2b-256 checksum How to use checksums |
d5d2eac9ea2a5ea14c87ddd193ae8274e4f864275b8f601f842a6f971d4279c6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 24, 2026.
Transparency log