Commit 9eba371
authored
feat(apl): generic-HTTP authorization (#110)
* feat(http): add HTTP request-line attributes to HttpExtension
Add optional method/path/host/scheme to HttpExtension and surface them in
the APL bag as http.method/path/host/scheme. These let CEL/APL policies
reason over the HTTP request line — needed by the Praxis AuthPolicy
transpiler, where Kuadrant predicates over request.method/path/host map to
http.* (Praxis spike Phase B / U1).
The request line rides the existing read_headers capability: the `http`
extension slot is gated as a whole in cpex-core's filter_extensions, so a
base-tier split would require granular http sub-field filtering (deferred).
The host field is documented to be populated from a validated authority
(e.g. HTTP/2 :authority), never a raw client Host header, so host-based
policy cannot be bypassed.
Signed-off-by: Frederico Araujo <frederico.araujo@ibm.com>
* feat(apl): carry custom denial response via PluginViolation.details
Add a per-route `response:` block (the transpiled form of a Kuadrant
AuthPolicy `denyWith`) that lets a route declare a custom HTTP status,
body, and headers for its denials (Praxis spike Phase B / U2).
- New optional DenyResponse on CompiledRoute (additive; most-specific
layer wins in apply_layer). Read out-of-band from the route YAML by the
apl-cpex visitor, like the `policy:` block — cpex-core tolerates the key.
- On Decision::Deny, route_handler stashes status/body/headers into the
existing PluginViolation.details map under http.status / http.body /
http.headers. No new fields on PluginViolation and no new APL grammar —
the violation type stays stable and reason-only denies are unchanged.
A host (e.g. the Praxis policy filter) reads details to render a custom
denial response; absent → host default behavior.
Signed-off-by: Frederico Araujo <frederico.araujo@ibm.com>
* feat(apl): evaluate the global policy for entity-less HTTP requests
Make the catch-all `global` policy enforce on generic (non-MCP/A2A) HTTP
requests, which carry no entity (Praxis spike Phase B / U3).
- New reserved coordinates: ENTITY_HTTP ("http") / ENTITY_NAME_GLOBAL ("*")
and the HOOK_CMF_HTTP_REQUEST ("cmf.http_request") hook.
- The visitor installs a Pre-phase AplRouteHandler bound to the compiled
global policy under those coordinates, granted read_headers so the
policy can read the request line/headers. Entity routes still stack
`global` via apply_layer; this adds the entity-less evaluation path.
- A global-scope `response:` block (transpiled denyWith) is carried onto
the global handler and surfaced on deny via PluginViolation.details (U2).
A host fires invoke_named::<CmfHook>("cmf.http_request", ...) with
meta.entity_type/name set to the reserved coordinates. End-to-end tests
cover allow, deny, and custom-denyWith — exercising U1 + U2 + U3 together.
Signed-off-by: Frederico Araujo <frederico.araujo@ibm.com>
* fix(apl): scope denyWith response to its owning scope
Address review feedback on the generic-HTTP authorization PR:
- Stop apply_layer from propagating `response`, so a `global` catch-all
denyWith no longer leaks onto inherited entity (tool/llm/prompt/resource)
denials with no opt-out.
- Decorate only genuine denials via a shared decorate_denial_response
helper, and apply it at the session load/persist fail-closed sites too
(previously they rendered the default shape).
- Warn when `response:` sits at default/policy-bundle scope, where it is
inert, instead of dropping it silently.
- Parse the route `response:` once above the per-entity loop.
- Extract snapshot_dispatch_state to share the registry/router/store
read between the global and per-route handler installs.
- Promote the http.status/body/headers detail keys to DETAIL_HTTP_*
constants shared by producer and consumer.
Signed-off-by: Frederico Araujo <frederico.araujo@ibm.com>
* style(apl): rustfmt + clippy fixes for denyWith tests
Signed-off-by: Frederico Araujo <frederico.araujo@ibm.com>
* fix(apl): close fail-open gaps in entity-less HTTP catch-all
Gate the catch-all handler install on args OR policy (not policy alone),
so an args-only global.apl still authorizes entity-less HTTP traffic.
Warn when a global response: is configured but no installable policy
exists, including the bare response-only block that hit visit_global's
early return. Accept response: nested under apl: as well as top-level,
with top-level taking precedence (documented as deliberate). Cover the
fail-closed session-store denials and the new paths with tests.
Signed-off-by: Frederico Araujo <frederico.araujo@ibm.com>
* docs(apl): document HTTP request-line attrs, response: block, and entity-less HTTP authz
Add http.method/path/host/scheme to the extensions and read_headers
tables. Document the route/global response: (denyWith) block and the
global-policy path that authorizes generic HTTP requests carrying no
MCP/A2A entity.
Signed-off-by: Frederico Araujo <frederico.araujo@ibm.com>
* docs(apl): drop internal design-doc cross-references from comments
Remove requirement/unit/spike identifiers (R5/R7/R8/R9/R10/R11/R14/R15/R16/R17/R18,
U1/U2/U3, AE1-AE6, spike phase, Praxis transpiler) from doc comments and test
descriptions across apl-core, apl-cpex, and the valkey session store. The
comments now describe behavior in their own terms rather than pointing at
private design docs the public repo doesn't carry.
Signed-off-by: Frederico Araujo <frederico.araujo@ibm.com>
* docs(apl): standardize examples on canonical authentication/authorization form
Migrate all human-facing APL examples to one canonical shape: no `apl:`
wrapper, with `authentication:` and `authorization:` as parallel sibling
blocks (pre_invocation/post_invocation nested under `authorization:`;
args/result/pdp/session_store/response as siblings).
- Strip the `apl:` wrapper from _index.md, valkey-session-store.md, and the
cedar-direct/cel PDP factory doc-comments; fix incidental `global.apl` /
"sibling of the `apl:` block" prose.
- Wrap the previously-flat `pre_invocation:` examples (README, quickstart,
overview, patterns, vision, deployment, tainting, effects, pdp, delegation)
under `authorization:`.
- Fix pre-existing invalid YAML in patterns.md and effects.md where the
`${args.*}` placeholder sat inside a flow mapping; expand to block form.
Docs/convention only; all forms remain accepted by the parser. `hugo --minify`
builds clean and every edited YAML block parses.
Signed-off-by: Frederico Araujo <frederico.araujo@ibm.com>
* test(apl): cover canonical authentication/authorization form
Give the canonical no-`apl:` shape real coverage:
- Convert the FFI (crates/cpex-ffi) and Go (go/cpex/apl_test.go) APL fixtures
off the `apl: { authorization: {...} }` wrapper to the canonical sibling
`authorization:` form.
- Add crates/apl-cpex/tests/canonical_authn_authz_e2e.rs: a self-contained
end-to-end test with a route declaring `authentication:` and
`authorization:` as siblings (no `apl:`), asserting the identity block
dispatches on identity.resolve and the pre_invocation phase runs on
cmf.tool_pre_invoke.
All touched suites pass (apl-cpex, apl-core, cpex-core, cpex-ffi, go).
Signed-off-by: Frederico Araujo <frederico.araujo@ibm.com>
* chore(release): bump workspace version to 0.2.1
Bump `[workspace.package] version` and the internal path-dep pins to 0.2.1
(members inherit via `version.workspace`), refresh Cargo.lock, and cut the
CHANGELOG `[Unreleased]` section as `[0.2.1]`.
0.2.1 collects the work landed since 0.2.0: HTTP request-line attributes,
the custom-denial `response:` block, entity-less HTTP authorization, the
PyO3 Python bindings, the authz/authn config-key rename, and the canonical
docs config shape.
Signed-off-by: Frederico Araujo <frederico.araujo@ibm.com>
* style(apl): rustfmt the canonical authn/authz e2e test
Reformat the adapter construction in the new test to satisfy
`cargo fmt --all --check` (the CI Lint job). No behavior change.
Signed-off-by: Frederico Araujo <frederico.araujo@ibm.com>
---------
Signed-off-by: Frederico Araujo <frederico.araujo@ibm.com>1 parent 8b18994 commit 9eba371
41 files changed
Lines changed: 1395 additions & 233 deletions
File tree
- builtins
- pdps
- cedar-direct/src
- cel/src
- session/valkey
- src
- tests
- crates
- apl-cmf/src
- apl-core/src
- apl-cpex
- src
- tests
- cpex-core/src
- cmf
- extensions
- cpex-ffi/src
- cpex
- docs
- content/docs
- apl
- operations
- go/cpex
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
17 | 24 | | |
18 | 25 | | |
19 | 26 | | |
| |||
24 | 31 | | |
25 | 32 | | |
26 | 33 | | |
| 34 | + | |
| 35 | + | |
27 | 36 | | |
28 | 37 | | |
29 | 38 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
65 | | - | |
| 65 | + | |
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| |||
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
57 | 58 | | |
58 | 59 | | |
59 | 60 | | |
60 | 61 | | |
61 | 62 | | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
69 | 71 | | |
70 | 72 | | |
71 | 73 | | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
77 | 80 | | |
78 | 81 | | |
79 | 82 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
19 | 18 | | |
20 | 19 | | |
21 | 20 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
15 | 14 | | |
16 | 15 | | |
17 | 16 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | | - | |
| 55 | + | |
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
60 | | - | |
| 60 | + | |
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
65 | | - | |
| 65 | + | |
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
93 | | - | |
| 93 | + | |
94 | 94 | | |
95 | | - | |
| 95 | + | |
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
| |||
152 | 152 | | |
153 | 153 | | |
154 | 154 | | |
155 | | - | |
| 155 | + | |
156 | 156 | | |
157 | 157 | | |
158 | 158 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| |||
0 commit comments