Skip to main content

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 bots to a cryptographic challenge. 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)

app = FastAPI()
app.add_middleware(
    UBAGMiddleware,
    origin="https://yoursite.com",
    issuer_key=issuer_private,                  # mints + verifies credentials
    # 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 bots, 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 per-request proof-of-possession via agent.headers(method, path).

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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ubag-0.4.0.tar.gz (28.4 kB view details)

Uploaded Source

Built Distribution

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

ubag-0.4.0-py3-none-any.whl (25.0 kB view details)

Uploaded Python 3

File details

Details for the file ubag-0.4.0.tar.gz.

File metadata

  • Download URL: ubag-0.4.0.tar.gz
  • Upload date:
  • Size: 28.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for ubag-0.4.0.tar.gz
Algorithm Hash digest
SHA256 769c898de98c83962c5b0c761f2e07f1f25e8a44818f8beb3daf01644d9f6a49
MD5 ada99ce13d91f215dc4750ec75b908c1
BLAKE2b-256 6ab3a8c10b19879ca148212f82b18ed2278653e44dd12a74a4b151f45ff16e58

See more details on using hashes here.

Provenance

The following attestation bundles were made for ubag-0.4.0.tar.gz:

Publisher: publish.yml on mohameduk/Ubag_protocol

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ubag-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: ubag-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 25.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for ubag-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 18259ec7c91c3cf31d043ccae905572e3c9bff6355c8e8253d4270ab810858be
MD5 a923713dccc761a702478e1643b4c94d
BLAKE2b-256 b9dfa863e3d3b328f9f711c13a60dd74bd82b98ca9b1a67135f3fb9cfb6919bf

See more details on using hashes here.

Provenance

The following attestation bundles were made for ubag-0.4.0-py3-none-any.whl:

Publisher: publish.yml on mohameduk/Ubag_protocol

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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