Skip to main content

cedarpy-integrations

Write a policy with your Python types and enums. Cedar still makes the decision.

Alice owns a document. She may read it while it's a draft. What happens when she seals it?

sealed = read_document.state == DocumentState.SEALED
owner_or_public = (read_document.owner == read_document.principal) | (
    read_document.state == DocumentState.PUBLIC
)

read = policy(
    read_document,
    permit_when=owner_or_public & ~sealed,
    forbid_when=sealed,
)
Alice reads her own draft document: allow
Alice reads her own sealed document: deny
See the Cedar this Python generates
permit (principal is User, action == Action::"read", resource is Document)
when {
  (((resource.owner) == principal) || ((resource.state) == "public")) &&
  (!((resource.state) == "sealed"))
};

forbid (principal is User, action == Action::"read", resource is Document)
when { (resource.state) == "sealed" };

Save sealed_document.py and run it. The script declares its dependencies, prints the generated Cedar, and checks both decisions. No checkout, web framework, or database is needed.

uv run sealed_document.py

Install an integration

Use Python 3.13 or later. The base cedarpy-integrations install includes typed policies, shared web permissions, and WSGI. Choose an extra if your application uses ASGI or FastAPI:

Use case Install Guide
Share typed policy expressions in Python uv add cedarpy-integrations Share policies in Python
Require permission on a FastAPI route uv add 'cedarpy-integrations[fastapi]' FastAPI
Protect a mounted ASGI app uv add 'cedarpy-integrations[asgi]' ASGI example
Protect Flask or Django views uv add cedarpy-integrations Flask or Django

The SQLAlchemy reader is available only as source in this repository. See when to use Python or Cedar before choosing a policy format.

Using the integrations

cedarpy_policy builds Cedar policy expressions from typed Python references. It does not fetch application data, replace Cedar schemas, or evaluate a request by itself. Use it when you want to define and share rules in Python. The policy guide shows how it fits with the schema and SQLAlchemy reader.

For an HTTP operation, authenticate the caller first and supply verified user and session facts to Cedar. See binding session facts.

For row access, map model columns to Cedar facts. The SQL reader narrows candidate rows and checks each candidate with the policy. It does not protect raw SQL, writes, or other sessions. See the SQLAlchemy API.

Without a framework, call cedarpy.is_authorized() directly. The example checks whether Alice and Bob may read the same document.

This project is licensed under Apache License 2.0. Vendored documentation and grammars retain their upstream notices.

The four import namespaces (cedarpy_policy, cedarpy_web, cedarpy_wsgi, and cedarpy_asgi) live under src/. The SQLAlchemy source stays in packages/sqlalchemy/src/. See the docs site for preview instructions and release verification for contributor checks.

Metadata

Release files for cedarpy-integrations 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 cedarpy-integrations 0.1.0
File Size Uploaded Provenance Actions
cedarpy_integrations-0.1.0.tar.gz 13.1 kB With provenance Details for cedarpy_integrations-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cedarpy-integrations 0.1.0
File Interpreter ABI Platform Actions
cedarpy_integrations-0.1.0-py3-none-any.whl Python 3 none any Details for cedarpy_integrations-0.1.0-py3-none-any.whl

Total release size: 29.0 kB

Release files / cedarpy_integrations-0.1.0.tar.gz

Download URL cedarpy_integrations-0.1.0.tar.gz
Size 13.1 kB
Tags Source
SHA-256 checksum
How to use checksums
f62a486b5cfb3a298fbc74a89e0f3612ada9adaf33c50fbc5cfe3032ae2a9e72
BLAKE2b-256 checksum
How to use checksums
23d3739de538adca8ddb5f85fa6eecc2dd647be6a261b24950ae056fca96dd4d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 23, 2026.

Transparency log

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

Download URL cedarpy_integrations-0.1.0-py3-none-any.whl
Size 15.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d5bed1bdd369968cd6a24b4116dfabdf80cda496f4eda7532181ddcfbf5f6063
BLAKE2b-256 checksum
How to use checksums
11a39c9b50d477a5ce5ec11b5cf40ff6fec88b62393ce5848ae53e9ba9207276
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 23, 2026.

Transparency log

Security for cedarpy-integrations 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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for cedarpy_integrations-0.1.0.tar.gz

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 Nov 23, 2026.

Transparency log

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 Full 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