Skip to main content

angel-verified-identity

WSGI and ASGI middleware for Angel apps. It verifies the signed Angel-Identity assertion on each request, then sets the identity headers from the verified claims. Flask, Django, FastAPI and Starlette share one implementation.

Install

pip install angel-verified-identity

Python 3.9 or later. The only dependency is cryptography.

Use

Wrap the whole application, not single routes, so that static files are covered too.

Flask (WSGI):

from flask import Flask, request
from angel_verified_identity import AngelIdentityWSGIMiddleware

app = Flask(__name__)
app.wsgi_app = AngelIdentityWSGIMiddleware(app.wsgi_app, probe_path="/admin")

@app.get("/admin")
def admin():
    return {"who": request.headers["X-Forwarded-Email"]}

FastAPI (ASGI):

from fastapi import FastAPI, Request
from angel_verified_identity import AngelIdentityASGIMiddleware

app = FastAPI()
app.add_middleware(AngelIdentityASGIMiddleware, probe_path="/admin")

@app.get("/admin")
def admin(request: Request):
    return {"who": request.headers["x-forwarded-email"]}

The verified claims are also in environ["angel.identity"] (WSGI) and scope["state"]["angel_identity"] (ASGI).

What it does

  1. Refuses a request that another app replayed to this app, with 403. It does this in both modes.
  2. Verifies the Angel-Identity header: a compact JWS, EdDSA over Ed25519.
  3. If the header is valid, deletes x-forwarded-email, x-forwarded-user, x-email and x-user, then sets them from the verified claims. It also sets x-angel-principal-type.
  4. If the header is not valid:
    • in enforce mode, deletes those headers and answers 401;
    • in observe mode, logs the failure and passes the request on unchanged. The headers are then not verified. Use observe only during a rollout.

Configuration

The middleware reads these environment variables.

Variable Meaning
FLY_APP_NAME The app's name, and the expected audience. Verification fails without it.
AVI_PUBLIC_KEYS The JWKS document with the public keys. Read first.
AVI_JWKS_URL JWKS URL, fetched only for an unknown key id. Cached for 5 minutes.
ANGEL_CONTROL_PLANE_URL Alternative to AVI_JWKS_URL. The library adds /.well-known/avi-jwks.json.
ANGEL_IDENTITY_MODE observe or enforce. The default is enforce.
ANGEL_WORKLOAD_ALLOW Comma-separated sub values that can call as typ: "workload".
ANGEL_ALLOW_REPLAY 1 turns off the replay check. Use it only if the app replays requests to itself.

Attestation endpoint

GET /_angel/avi-attestation returns the declared probe path and the current mode. It answers 503 if no probe path is declared. Declare it with the probe_path argument, or call register_probe_path("/admin") before the app serves a request.

Metadata

Release files for angel-verified-identity 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for angel-verified-identity 0.1.0
File Size Uploaded Provenance Actions
angel_verified_identity-0.1.0.tar.gz 17.7 kB Without provenance Details for angel_verified_identity-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for angel-verified-identity 0.1.0
File Interpreter ABI Platform Actions
angel_verified_identity-0.1.0-py3-none-any.whl Python 3 none any Details for angel_verified_identity-0.1.0-py3-none-any.whl

Total release size: 39.5 kB

Release files / angel_verified_identity-0.1.0.tar.gz

Download URL angel_verified_identity-0.1.0.tar.gz
Size 17.7 kB
Tags Source
SHA-256 checksum
How to use checksums
7d736b44c6b7d90e94fba11904a2f810c7f9483ca9ac48c7a1e1abe162dfc253
BLAKE2b-256 checksum
How to use checksums
e727da232f3f51a40e18f9cb368f4d2e8bca30f88036f3f4e8ee2b0ee117ad83
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / angel_verified_identity-0.1.0-py3-none-any.whl

Download URL angel_verified_identity-0.1.0-py3-none-any.whl
Size 21.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2215f772a3520e45580a0932a1e067784696bb7b44daa4e1c4c74a847dd1cf76
BLAKE2b-256 checksum
How to use checksums
b0ba798790142061a7d3168773b1852e2241d6eba9c91ebbf30f853f2e66c747
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Security for angel-verified-identity 0.1.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page