sentrykit 0.1.0rc1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sentrykit-0.1.0rc1/.gitignore +44 -0
- sentrykit-0.1.0rc1/CHANGELOG.md +141 -0
- sentrykit-0.1.0rc1/LICENSE +201 -0
- sentrykit-0.1.0rc1/PKG-INFO +541 -0
- sentrykit-0.1.0rc1/README.md +493 -0
- sentrykit-0.1.0rc1/SECURITY.md +196 -0
- sentrykit-0.1.0rc1/dev-docs/api-surface.md +221 -0
- sentrykit-0.1.0rc1/dev-docs/architecture.md +200 -0
- sentrykit-0.1.0rc1/dev-docs/coding-standards.md +49 -0
- sentrykit-0.1.0rc1/dev-docs/design-decisions.md +1264 -0
- sentrykit-0.1.0rc1/dev-docs/documentation-standards.md +251 -0
- sentrykit-0.1.0rc1/dev-docs/implementation.md +314 -0
- sentrykit-0.1.0rc1/dev-docs/logging-standards.md +42 -0
- sentrykit-0.1.0rc1/dev-docs/notes/phase-1-research.md +189 -0
- sentrykit-0.1.0rc1/dev-docs/notes/phase-2-research.md +234 -0
- sentrykit-0.1.0rc1/dev-docs/notes/phase-3-research.md +206 -0
- sentrykit-0.1.0rc1/dev-docs/notes/phase-4-research.md +373 -0
- sentrykit-0.1.0rc1/dev-docs/notes/phase-5-research.md +205 -0
- sentrykit-0.1.0rc1/dev-docs/notes/release-hardening-research.md +338 -0
- sentrykit-0.1.0rc1/dev-docs/packaging-standards.md +163 -0
- sentrykit-0.1.0rc1/dev-docs/pre-release-history.md +1030 -0
- sentrykit-0.1.0rc1/dev-docs/release-process.md +222 -0
- sentrykit-0.1.0rc1/dev-docs/testing-standards.md +46 -0
- sentrykit-0.1.0rc1/docs/agents.md +696 -0
- sentrykit-0.1.0rc1/docs/api/core.md +100 -0
- sentrykit-0.1.0rc1/docs/api/index.md +18 -0
- sentrykit-0.1.0rc1/docs/api/integrations.md +54 -0
- sentrykit-0.1.0rc1/docs/api/policy.md +20 -0
- sentrykit-0.1.0rc1/docs/api/sentrykit.md +15 -0
- sentrykit-0.1.0rc1/docs/api/stores.md +65 -0
- sentrykit-0.1.0rc1/docs/audit.md +418 -0
- sentrykit-0.1.0rc1/docs/concepts.md +443 -0
- sentrykit-0.1.0rc1/docs/conf.py +529 -0
- sentrykit-0.1.0rc1/docs/index.md +57 -0
- sentrykit-0.1.0rc1/docs/plugins.md +221 -0
- sentrykit-0.1.0rc1/docs/policies.md +621 -0
- sentrykit-0.1.0rc1/docs/quickstart.md +323 -0
- sentrykit-0.1.0rc1/docs/scenarios.md +164 -0
- sentrykit-0.1.0rc1/docs/web-frameworks.md +632 -0
- sentrykit-0.1.0rc1/examples/__init__.py +1 -0
- sentrykit-0.1.0rc1/examples/desk/__init__.py +121 -0
- sentrykit-0.1.0rc1/examples/desk/database.py +244 -0
- sentrykit-0.1.0rc1/examples/desk/models.py +344 -0
- sentrykit-0.1.0rc1/examples/desk/queries.py +689 -0
- sentrykit-0.1.0rc1/examples/desk/seed.py +583 -0
- sentrykit-0.1.0rc1/examples/fastapi_app/README.md +423 -0
- sentrykit-0.1.0rc1/examples/fastapi_app/__init__.py +1 -0
- sentrykit-0.1.0rc1/examples/fastapi_app/main.py +412 -0
- sentrykit-0.1.0rc1/examples/fastapi_app/policies/10-orders.cedar +84 -0
- sentrykit-0.1.0rc1/examples/fastapi_app/policies/20-refunds.cedar +58 -0
- sentrykit-0.1.0rc1/examples/fastapi_app/policy.py +224 -0
- sentrykit-0.1.0rc1/examples/fastapi_app/service.py +293 -0
- sentrykit-0.1.0rc1/examples/flask_app/README.md +441 -0
- sentrykit-0.1.0rc1/examples/flask_app/__init__.py +1 -0
- sentrykit-0.1.0rc1/examples/flask_app/main.py +413 -0
- sentrykit-0.1.0rc1/examples/flask_app/policies/10-orders.cedar +84 -0
- sentrykit-0.1.0rc1/examples/flask_app/policies/20-refunds.cedar +58 -0
- sentrykit-0.1.0rc1/examples/flask_app/policy.py +224 -0
- sentrykit-0.1.0rc1/examples/flask_app/service.py +293 -0
- sentrykit-0.1.0rc1/examples/mcp_server/README.md +681 -0
- sentrykit-0.1.0rc1/examples/mcp_server/__init__.py +1 -0
- sentrykit-0.1.0rc1/examples/mcp_server/policies/10-orders.cedar +87 -0
- sentrykit-0.1.0rc1/examples/mcp_server/policies/20-refunds.cedar +57 -0
- sentrykit-0.1.0rc1/examples/mcp_server/policy.py +232 -0
- sentrykit-0.1.0rc1/examples/mcp_server/server.py +622 -0
- sentrykit-0.1.0rc1/examples/mcp_server/service.py +329 -0
- sentrykit-0.1.0rc1/examples/models.py +392 -0
- sentrykit-0.1.0rc1/examples/ollama.py +218 -0
- sentrykit-0.1.0rc1/examples/pydantic_ai_agent/README.md +607 -0
- sentrykit-0.1.0rc1/examples/pydantic_ai_agent/__init__.py +1 -0
- sentrykit-0.1.0rc1/examples/pydantic_ai_agent/agent.py +708 -0
- sentrykit-0.1.0rc1/examples/pydantic_ai_agent/policies/10-orders.cedar +79 -0
- sentrykit-0.1.0rc1/examples/pydantic_ai_agent/policies/20-refunds.cedar +48 -0
- sentrykit-0.1.0rc1/examples/pydantic_ai_agent/policy.py +212 -0
- sentrykit-0.1.0rc1/examples/pydantic_ai_agent/service.py +296 -0
- sentrykit-0.1.0rc1/examples/scenarios/README.md +211 -0
- sentrykit-0.1.0rc1/examples/scenarios/__init__.py +40 -0
- sentrykit-0.1.0rc1/examples/scenarios/__main__.py +215 -0
- sentrykit-0.1.0rc1/examples/scenarios/attack.py +140 -0
- sentrykit-0.1.0rc1/examples/scenarios/desk_tools.py +293 -0
- sentrykit-0.1.0rc1/examples/scenarios/governed.py +117 -0
- sentrykit-0.1.0rc1/examples/scenarios/harness.py +495 -0
- sentrykit-0.1.0rc1/examples/scenarios/policies/10-desk.cedar +102 -0
- sentrykit-0.1.0rc1/examples/scenarios/policies/20-exports.cedar +55 -0
- sentrykit-0.1.0rc1/examples/scenarios/policy.py +225 -0
- sentrykit-0.1.0rc1/examples/scenarios/scenarios.py +305 -0
- sentrykit-0.1.0rc1/pixi.toml +215 -0
- sentrykit-0.1.0rc1/pyproject.toml +207 -0
- sentrykit-0.1.0rc1/scripts/build_llms_txt.py +446 -0
- sentrykit-0.1.0rc1/scripts/check_commit_msg.py +79 -0
- sentrykit-0.1.0rc1/scripts/clean.py +85 -0
- sentrykit-0.1.0rc1/scripts/coverage_gate.py +142 -0
- sentrykit-0.1.0rc1/scripts/release_check.py +345 -0
- sentrykit-0.1.0rc1/src/sentrykit/__init__.py +200 -0
- sentrykit-0.1.0rc1/src/sentrykit/audit.py +967 -0
- sentrykit-0.1.0rc1/src/sentrykit/cedar.py +750 -0
- sentrykit-0.1.0rc1/src/sentrykit/cli.py +1405 -0
- sentrykit-0.1.0rc1/src/sentrykit/config.py +300 -0
- sentrykit-0.1.0rc1/src/sentrykit/constraints.py +928 -0
- sentrykit-0.1.0rc1/src/sentrykit/context.py +393 -0
- sentrykit-0.1.0rc1/src/sentrykit/decorator.py +252 -0
- sentrykit-0.1.0rc1/src/sentrykit/engine.py +1509 -0
- sentrykit-0.1.0rc1/src/sentrykit/envelope.py +513 -0
- sentrykit-0.1.0rc1/src/sentrykit/errors.py +252 -0
- sentrykit-0.1.0rc1/src/sentrykit/integrations/__init__.py +1 -0
- sentrykit-0.1.0rc1/src/sentrykit/integrations/base.py +767 -0
- sentrykit-0.1.0rc1/src/sentrykit/integrations/fastapi.py +361 -0
- sentrykit-0.1.0rc1/src/sentrykit/integrations/flask.py +342 -0
- sentrykit-0.1.0rc1/src/sentrykit/integrations/mcp.py +929 -0
- sentrykit-0.1.0rc1/src/sentrykit/integrations/pydantic_ai.py +728 -0
- sentrykit-0.1.0rc1/src/sentrykit/integrations/tools.py +479 -0
- sentrykit-0.1.0rc1/src/sentrykit/masking.py +459 -0
- sentrykit-0.1.0rc1/src/sentrykit/policy/__init__.py +40 -0
- sentrykit-0.1.0rc1/src/sentrykit/policy/loader.py +764 -0
- sentrykit-0.1.0rc1/src/sentrykit/policy/pack/10-rbac.cedar +9 -0
- sentrykit-0.1.0rc1/src/sentrykit/policy/pack/20-groups.cedar +9 -0
- sentrykit-0.1.0rc1/src/sentrykit/policy/pack/30-ownership.cedar +8 -0
- sentrykit-0.1.0rc1/src/sentrykit/policy/pack/40-delegation.cedar +40 -0
- sentrykit-0.1.0rc1/src/sentrykit/policy/pack/50-expiry.cedar +24 -0
- sentrykit-0.1.0rc1/src/sentrykit/policy/pack/60-break-glass.cedar +34 -0
- sentrykit-0.1.0rc1/src/sentrykit/policy/pack/70-separation-of-duties.cedar +22 -0
- sentrykit-0.1.0rc1/src/sentrykit/policy/pack/80-jit-elevation.cedar +32 -0
- sentrykit-0.1.0rc1/src/sentrykit/policy/pack/entities.json +3 -0
- sentrykit-0.1.0rc1/src/sentrykit/policy/pack/pack.cedarschema +45 -0
- sentrykit-0.1.0rc1/src/sentrykit/policy/pack/templates/time-boxed-grant.cedartemplate +5 -0
- sentrykit-0.1.0rc1/src/sentrykit/py.typed +0 -0
- sentrykit-0.1.0rc1/src/sentrykit/registry.py +666 -0
- sentrykit-0.1.0rc1/src/sentrykit/stores/__init__.py +116 -0
- sentrykit-0.1.0rc1/src/sentrykit/stores/base.py +870 -0
- sentrykit-0.1.0rc1/src/sentrykit/stores/composite.py +635 -0
- sentrykit-0.1.0rc1/src/sentrykit/stores/filesystem.py +400 -0
- sentrykit-0.1.0rc1/src/sentrykit/stores/jsonfile.py +701 -0
- sentrykit-0.1.0rc1/src/sentrykit/stores/jsonl.py +357 -0
- sentrykit-0.1.0rc1/src/sentrykit/stores/memory.py +500 -0
- sentrykit-0.1.0rc1/tests/conftest.py +283 -0
- sentrykit-0.1.0rc1/tests/integration/.gitkeep +0 -0
- sentrykit-0.1.0rc1/tests/integration/conftest.py +869 -0
- sentrykit-0.1.0rc1/tests/integration/test_agent_context_isolation.py +402 -0
- sentrykit-0.1.0rc1/tests/integration/test_agent_provider_discovery.py +166 -0
- sentrykit-0.1.0rc1/tests/integration/test_documented_examples_agents.py +1716 -0
- sentrykit-0.1.0rc1/tests/integration/test_documented_examples_web.py +578 -0
- sentrykit-0.1.0rc1/tests/integration/test_entity_valued_arguments.py +158 -0
- sentrykit-0.1.0rc1/tests/integration/test_fastapi_provider.py +142 -0
- sentrykit-0.1.0rc1/tests/integration/test_flask_provider.py +122 -0
- sentrykit-0.1.0rc1/tests/integration/test_mcp_provider.py +487 -0
- sentrykit-0.1.0rc1/tests/integration/test_narrowing_out_of_band.py +341 -0
- sentrykit-0.1.0rc1/tests/integration/test_plugin_discovery.py +183 -0
- sentrykit-0.1.0rc1/tests/integration/test_pydantic_ai_provider.py +503 -0
- sentrykit-0.1.0rc1/tests/integration/test_release_artifacts.py +299 -0
- sentrykit-0.1.0rc1/tests/integration/test_web_context_isolation.py +262 -0
- sentrykit-0.1.0rc1/tests/integration/test_web_provider_discovery.py +103 -0
- sentrykit-0.1.0rc1/tests/scenarios/.gitkeep +0 -0
- sentrykit-0.1.0rc1/tests/scenarios/conftest.py +314 -0
- sentrykit-0.1.0rc1/tests/scenarios/test_ab_harness.py +382 -0
- sentrykit-0.1.0rc1/tests/scenarios/test_break_glass.py +139 -0
- sentrykit-0.1.0rc1/tests/scenarios/test_cli_admin.py +253 -0
- sentrykit-0.1.0rc1/tests/scenarios/test_composition.py +145 -0
- sentrykit-0.1.0rc1/tests/scenarios/test_delegation.py +169 -0
- sentrykit-0.1.0rc1/tests/scenarios/test_documented_scenarios.py +275 -0
- sentrykit-0.1.0rc1/tests/scenarios/test_expiry.py +190 -0
- sentrykit-0.1.0rc1/tests/scenarios/test_jit_elevation.py +123 -0
- sentrykit-0.1.0rc1/tests/scenarios/test_rbac_groups_ownership.py +154 -0
- sentrykit-0.1.0rc1/tests/scenarios/test_reporting.py +394 -0
- sentrykit-0.1.0rc1/tests/scenarios/test_separation_of_duties.py +118 -0
- sentrykit-0.1.0rc1/tests/unit/conftest.py +71 -0
- sentrykit-0.1.0rc1/tests/unit/test_argument_ceilings.py +702 -0
- sentrykit-0.1.0rc1/tests/unit/test_audit.py +530 -0
- sentrykit-0.1.0rc1/tests/unit/test_audit_and_masking_settings.py +139 -0
- sentrykit-0.1.0rc1/tests/unit/test_audit_invariants.py +726 -0
- sentrykit-0.1.0rc1/tests/unit/test_audit_report.py +661 -0
- sentrykit-0.1.0rc1/tests/unit/test_cedar.py +351 -0
- sentrykit-0.1.0rc1/tests/unit/test_cedar_confinement.py +119 -0
- sentrykit-0.1.0rc1/tests/unit/test_cedarpy_contract.py +288 -0
- sentrykit-0.1.0rc1/tests/unit/test_cli.py +917 -0
- sentrykit-0.1.0rc1/tests/unit/test_commit_history.py +141 -0
- sentrykit-0.1.0rc1/tests/unit/test_commit_msg_gate.py +48 -0
- sentrykit-0.1.0rc1/tests/unit/test_composite.py +662 -0
- sentrykit-0.1.0rc1/tests/unit/test_config.py +170 -0
- sentrykit-0.1.0rc1/tests/unit/test_constraint_consistency.py +523 -0
- sentrykit-0.1.0rc1/tests/unit/test_constraints.py +778 -0
- sentrykit-0.1.0rc1/tests/unit/test_context.py +340 -0
- sentrykit-0.1.0rc1/tests/unit/test_contextmanager_annotations.py +161 -0
- sentrykit-0.1.0rc1/tests/unit/test_core_imports.py +108 -0
- sentrykit-0.1.0rc1/tests/unit/test_decorator.py +367 -0
- sentrykit-0.1.0rc1/tests/unit/test_desk_database.py +479 -0
- sentrykit-0.1.0rc1/tests/unit/test_desk_scenario_queries.py +539 -0
- sentrykit-0.1.0rc1/tests/unit/test_documented_examples.py +180 -0
- sentrykit-0.1.0rc1/tests/unit/test_documented_examples_pack_and_report.py +612 -0
- sentrykit-0.1.0rc1/tests/unit/test_documented_examples_policies_audit_plugins.py +476 -0
- sentrykit-0.1.0rc1/tests/unit/test_engine.py +1611 -0
- sentrykit-0.1.0rc1/tests/unit/test_envelope.py +479 -0
- sentrykit-0.1.0rc1/tests/unit/test_errors.py +92 -0
- sentrykit-0.1.0rc1/tests/unit/test_example_model_tiers_are_off_in_tests.py +89 -0
- sentrykit-0.1.0rc1/tests/unit/test_example_models.py +668 -0
- sentrykit-0.1.0rc1/tests/unit/test_integrations_base.py +781 -0
- sentrykit-0.1.0rc1/tests/unit/test_integrations_tools.py +575 -0
- sentrykit-0.1.0rc1/tests/unit/test_masking.py +361 -0
- sentrykit-0.1.0rc1/tests/unit/test_policy_loader.py +473 -0
- sentrykit-0.1.0rc1/tests/unit/test_policy_pack.py +549 -0
- sentrykit-0.1.0rc1/tests/unit/test_registry.py +376 -0
- sentrykit-0.1.0rc1/tests/unit/test_relationships.py +176 -0
- sentrykit-0.1.0rc1/tests/unit/test_reserved_keys.py +223 -0
- sentrykit-0.1.0rc1/tests/unit/test_scenario_tools.py +295 -0
- sentrykit-0.1.0rc1/tests/unit/test_smoke.py +30 -0
- sentrykit-0.1.0rc1/tests/unit/test_stores_filesystem.py +361 -0
- sentrykit-0.1.0rc1/tests/unit/test_stores_jsonfile.py +751 -0
- sentrykit-0.1.0rc1/tests/unit/test_stores_jsonl.py +427 -0
- sentrykit-0.1.0rc1/tests/unit/test_stores_memory.py +334 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*.egg-info/
|
|
5
|
+
.eggs/
|
|
6
|
+
build/
|
|
7
|
+
dist/
|
|
8
|
+
*.so
|
|
9
|
+
|
|
10
|
+
# Testing / coverage
|
|
11
|
+
.pytest_cache/
|
|
12
|
+
.mypy_cache/
|
|
13
|
+
.ruff_cache/
|
|
14
|
+
# Hypothesis writes its own `.hypothesis/.gitignore` containing `*`, so git has always
|
|
15
|
+
# skipped this -- which is why it is easy to miss that nothing else does. The sdist builder
|
|
16
|
+
# does not read nested ignore files, and shipped 328 cache files until it was named here.
|
|
17
|
+
.hypothesis/
|
|
18
|
+
.coverage
|
|
19
|
+
coverage.xml
|
|
20
|
+
htmlcov/
|
|
21
|
+
|
|
22
|
+
# pixi
|
|
23
|
+
.pixi/
|
|
24
|
+
# keep pixi.lock committed for reproducible dev envs
|
|
25
|
+
|
|
26
|
+
# Env / editors
|
|
27
|
+
.venv/
|
|
28
|
+
venv/
|
|
29
|
+
.env
|
|
30
|
+
.idea/
|
|
31
|
+
.vscode/
|
|
32
|
+
.DS_Store
|
|
33
|
+
|
|
34
|
+
# sentrykit local artifacts (never commit real audit logs or secrets)
|
|
35
|
+
*.audit.jsonl
|
|
36
|
+
secrets.local.*
|
|
37
|
+
|
|
38
|
+
# The example apps' demo database, when SENTRYKIT_DEMO_DB points at a file rather than
|
|
39
|
+
# letting it live in memory. Seeded from code and reproducible, so there is nothing here
|
|
40
|
+
# worth committing and a stale copy is worse than none.
|
|
41
|
+
examples/.demo/
|
|
42
|
+
|
|
43
|
+
# Local research workspace (not shipped, not committed)
|
|
44
|
+
/research/
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented here. Format follows
|
|
4
|
+
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/); versioning follows SemVer.
|
|
5
|
+
|
|
6
|
+
## [Unreleased]
|
|
7
|
+
|
|
8
|
+
<!-- Add an entry in the *fix & document* step of each loop iteration. -->
|
|
9
|
+
|
|
10
|
+
## [0.1.0] - 2026-11-09
|
|
11
|
+
|
|
12
|
+
The first release.
|
|
13
|
+
|
|
14
|
+
sentrykit is a self-hosted, framework-agnostic authorization layer for Python, built on
|
|
15
|
+
[AWS Cedar](https://www.cedarpolicy.com/). Clip one `@protect` decorator onto any callable — a
|
|
16
|
+
web route, a plain function, an agent tool — and it decides, per call, whether the principal may
|
|
17
|
+
invoke it, **which arguments they may pass**, and **which defaults to inject when they pass
|
|
18
|
+
none**, then writes a masked, hash-chained record of what it decided. The caller proposes; the
|
|
19
|
+
policy decides, and what it decides includes the arguments, not only the call.
|
|
20
|
+
|
|
21
|
+
Version numbers below this one appear in the project's development history. None was ever tagged
|
|
22
|
+
or published, so this is the first release anyone can install, and it is the whole library.
|
|
23
|
+
|
|
24
|
+
### Added
|
|
25
|
+
|
|
26
|
+
- **`@protect`, and one pipeline behind it.** The decorator guards any sync or async callable and
|
|
27
|
+
runs gate, filter the proposed arguments, inject the defaults policy supplies, validate,
|
|
28
|
+
invoke, report. One module imports `cedarpy`, parsing the policy set, the entity graph and an
|
|
29
|
+
optional schema at wiring time and reusing those handles per decision. The core imports no web
|
|
30
|
+
framework and no agent SDK, so the decision path is identical wherever it runs.
|
|
31
|
+
- **Ambient context, fail-closed.** `establish()` binds the principal, the channel and the facts
|
|
32
|
+
a policy may read — `now`, `break_glass`, `on_behalf_of`, `justification`; `bind_context()`
|
|
33
|
+
carries the scope across a thread-pool offload. With no principal established the call is
|
|
34
|
+
refused rather than run unguarded, so forgetting to wire a boundary denies instead of opening.
|
|
35
|
+
- **Per-(principal, action) argument constraints.** Allow-sets, deny-sets, patterns, numeric
|
|
36
|
+
bounds, `required` and a per-principal `default`, resolved for the principal and the action and
|
|
37
|
+
decided one argument at a time. A deny-set is matched against what a value *contains* as well
|
|
38
|
+
as against the value itself, so wrapping a forbidden value in a list does not get it past.
|
|
39
|
+
- **Narrow-and-continue instead of refuse.** A proposed value the principal may not have is
|
|
40
|
+
rejected and their own default fills the gap, so the call proceeds. It is reject-and-refill
|
|
41
|
+
rather than a clamp: the bound a value breached is never substituted for it. With no default
|
|
42
|
+
the argument is dropped, and if nothing the caller supplied survives the call is refused with
|
|
43
|
+
`NoValidArguments` — narrowing refines a proposal, it does not invent one.
|
|
44
|
+
- **Policy-supplied defaults, checked like everything else.** A default fills an argument the
|
|
45
|
+
caller omitted *and* one that was just dropped, and is itself checked against the constraint
|
|
46
|
+
governing it and withheld if it fails, so omitting an argument is not a way around its rule. A
|
|
47
|
+
constraint nothing could satisfy — an uncompilable pattern, a minimum above a maximum, an
|
|
48
|
+
allow-set member the other rules reject, a default the constraint would refuse — is refused at
|
|
49
|
+
the grant write rather than found by whoever calls next.
|
|
50
|
+
- **A governed parameter cannot quietly take its value from the function definition.** Where a
|
|
51
|
+
parameter has no surviving value, Python would fill the slot from the callable's own signature,
|
|
52
|
+
which no constraint ever saw. One that satisfies its constraint is named in
|
|
53
|
+
`signature_defaults`; one that does not refuses the call with `SignatureDefaultRejected`, whose
|
|
54
|
+
`declared` flag says whether the rule was reviewed policy or the principal's own grant.
|
|
55
|
+
- **Argument ceilings, declared in reviewed policy text.** A `@constraints` annotation on a Cedar
|
|
56
|
+
`permit` carries `{argument: {rule: value}}` and says what *anybody* may pass for that action.
|
|
57
|
+
Ceilings and grants intersect and can only narrow — allow-sets intersect, deny-sets union,
|
|
58
|
+
bounds move inward, `required` is sticky, two patterns must both match — and a ceiling may not
|
|
59
|
+
set a `default`, because per-principal values stay in the store. Declarations are checked at
|
|
60
|
+
load, since Cedar does not type-check annotation values, and a policy set declaring any ceiling
|
|
61
|
+
refuses an engine failure rather than proceeding unbounded. A ceiling is the one declaration a
|
|
62
|
+
policy can make that reaches narrow-and-continue rather than the gate.
|
|
63
|
+
- **An envelope that reports the outcome, not only the exceptions.** Every decision reports what
|
|
64
|
+
was processed, rejected, defaulted and withheld, trimmed by `verbosity`, plus `narrowed`,
|
|
65
|
+
`narrowed_arguments` and `guidance` — a narrowed call *succeeds*, on values the principal is
|
|
66
|
+
entitled to, and reporting only its exceptions describes that success in the vocabulary of a
|
|
67
|
+
failure. Those three name no value and no policy id, so a caller who may not be told *what* was
|
|
68
|
+
narrowed is still told *that* the result is good. It arrives as the `_authz` key on a mapping
|
|
69
|
+
return, via `last_envelope()` for any other return type, and out of band per boundary:
|
|
70
|
+
`x-sentrykit-narrowed` response headers, MCP `_meta` keys with an appended text block, and a
|
|
71
|
+
Pydantic-AI `ToolReturn` that displaces no data.
|
|
72
|
+
- **A refusal says which kind it is**: `AuthzDenied` for a policy denial, `NoContext` for no
|
|
73
|
+
principal, and `NoValidArguments`, `DefaultUnavailable`, `ArgumentRejected`,
|
|
74
|
+
`SignatureDefaultRejected`, `ReservedKey` and `ValidationFailed` for the argument layer.
|
|
75
|
+
`fail_mode` arbitrates engine failure alone: a denial and a missing principal deny either way.
|
|
76
|
+
- **Relationships resolved by Cedar's entity hierarchy.** Nested relationships spanning entities
|
|
77
|
+
— user → team → division → project → resource, delegation, on-behalf-of, expiry,
|
|
78
|
+
break-the-glass — resolve deterministically rather than through a ladder of application `if`
|
|
79
|
+
statements, so a policy names only the far end of a chain and severing one edge ends the access.
|
|
80
|
+
- **A masked, hash-chained audit trail.** One record per decision and per admin mutation: the
|
|
81
|
+
principal's effective attributes at decision time, the arguments proposed, processed, rejected
|
|
82
|
+
and defaulted, the policies that decided, and a `policy_set_hash` pinning the record to the
|
|
83
|
+
exact policy text. Sensitive values are masked *before* the append-only write, never at report
|
|
84
|
+
time — `redact`, `partial`, `hmac` or `tokenize`, chosen by a Cedar obligation, an
|
|
85
|
+
`Annotated[..., Sensitive(...)]` marker or the configured default, with keyed HMAC the default
|
|
86
|
+
because it alone lets an auditor correlate records without the store holding the value; a
|
|
87
|
+
principal's own allow-set, deny-set and pattern are masked the same way. Each record's hash
|
|
88
|
+
covers its predecessor's, so `verify_chain` catches an edited record and a deleted one, and a
|
|
89
|
+
record a sink refused is admitted by the next that lands, so an outage cannot read as an intact
|
|
90
|
+
window. Tampering is detected, not prevented.
|
|
91
|
+
- **Four context providers, each one extra line of wiring.** `FastAPIProvider` (pure-ASGI
|
|
92
|
+
middleware, an `async` context dependency, error handlers, `protect_app`), `FlaskProvider`
|
|
93
|
+
(`before_request` / `teardown_request`, `protect_app`, `protect_blueprint`), `MCPProvider`
|
|
94
|
+
(middleware around `tools/call`, `governed_tool`, `protect_server`) and `PydanticAIProvider`
|
|
95
|
+
(`RunContext.deps` bridged to ambient context, `governed_tool`, `tool_adapter`, `tool_prepare`,
|
|
96
|
+
`tool_filter`). Each establishes the principal at the boundary and renders a refusal in that
|
|
97
|
+
boundary's vocabulary; one built with no `identify=` warns once, because its own fallback ends
|
|
98
|
+
at something the request supplies.
|
|
99
|
+
- **Per-caller tool manifests, filtered by the decision that enforces the call.** A tool is
|
|
100
|
+
hidden from a principal if and only if invoking it would be refused. Hiding is a courtesy to
|
|
101
|
+
the model and never the control: a client that skips the manifest and calls a hidden tool by
|
|
102
|
+
name is refused the same. Arguments policy supplies are re-advertised as optional, so a model
|
|
103
|
+
can omit them and receive its own defaults.
|
|
104
|
+
- **A Cedar policy pack, shipped as data.** Eight domain-neutral patterns — `rbac`, `groups`,
|
|
105
|
+
`ownership`, `delegation`, `expiry`, `break-glass`, `separation-of-duties`, `jit-elevation` —
|
|
106
|
+
under a `pack://` DSN, composed through the same union as your own directory. None names a
|
|
107
|
+
role, a resource type or an action: the resource declares what it requires and the grant store
|
|
108
|
+
supplies the principal's edges. Half the pack **forbids**, and that half is what contains
|
|
109
|
+
rather than permits — reopening an emergency-only resource demands an entitlement, the flag
|
|
110
|
+
*and* a justification, because a permit conditioned on a caller-supplied boolean alone
|
|
111
|
+
authorizes anyone. The schema is opt-in, `link_template` makes a time-boxed grant from a Cedar
|
|
112
|
+
template, and the pack ships no permit for the admin actions: a library does not get to ship
|
|
113
|
+
the rule that hands out authority.
|
|
114
|
+
- **Four extension points, one mechanism.** Policy sources, grant stores, audit sinks and context
|
|
115
|
+
providers are each a `Protocol`, a DSN, a `register_*` decorator and an entry point, so a
|
|
116
|
+
third-party backend is indistinguishable from a built-in. Shipped: `file://` and `pack://`
|
|
117
|
+
policy sources, `memory://` and `jsonfile://` grant stores, `memory://` and `jsonl://` audit
|
|
118
|
+
sinks. Pass a list instead of one DSN and the composite satisfies the same `Protocol` — sources
|
|
119
|
+
union, grant stores merge or route by namespace, sinks fan out.
|
|
120
|
+
- **The `sentrykit` command line**, over `argparse` and no added dependency. `policy validate`
|
|
121
|
+
type-checks a directory against its schema, groups errors by `@id` and exits non-zero, so it
|
|
122
|
+
belongs in CI. `grant`, `revoke` and `grants` are the admin surface, each a protected callable
|
|
123
|
+
decided by the same governor the application uses — built from the policy-processed arguments
|
|
124
|
+
and not from `argv`, so a policy governs who may administer grants *and which grants they may
|
|
125
|
+
make*. `audit-report` windows a sink into markdown, aggregating by outcome, with a tamper
|
|
126
|
+
verdict and its own mutations section.
|
|
127
|
+
- **Five runnable examples over one shared domain.** An orders-and-refunds desk modelled
|
|
128
|
+
identically as a FastAPI app, a Flask app, an MCP tool server and a Pydantic-AI agent — the
|
|
129
|
+
same protected callables, the same reviewed `.cedar` directory and the same grant data, so only
|
|
130
|
+
the boundary wiring differs — each driving its flows against a seeded database and printing
|
|
131
|
+
what policy did to every call. The fifth proposes nine named attacks, from exfiltration by
|
|
132
|
+
`limit` and an instruction planted in a ticket thread to a destructive call whose damage sits
|
|
133
|
+
in its Python default, and runs each twice over the same function bodies: once past the policy
|
|
134
|
+
and once around it. Three of the nine the gate does not win, and they are in the suite on
|
|
135
|
+
purpose — a layer that ships only the cases it wins describes a feature, not a boundary.
|
|
136
|
+
- **Python 3.11, 3.12 and 3.13**, on a typed, documented public API: `mypy --strict` over the
|
|
137
|
+
package, `py.typed` in the wheel, and the docstrings the API reference is generated from. The
|
|
138
|
+
extras install only what a boundary needs — `fastapi`, `flask`, `mcp`, `pydantic-ai`, `web`,
|
|
139
|
+
`agents`, `all` — and the one core pin worth knowing about is `cedarpy >= 4.8, < 5`, the floor
|
|
140
|
+
exposing the parse-once API the engine is built on. Each release attaches the documentation as
|
|
141
|
+
HTML, a PDF, `llms.txt` and `llms-full.txt`, the last meant to be sufficient on its own.
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or Derivative
|
|
95
|
+
Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|