aac-invoke-auth 0.1.0__py3-none-any.whl
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.
- aac_invoke_auth/__init__.py +368 -0
- aac_invoke_auth/fastapi.py +369 -0
- aac_invoke_auth/py.typed +0 -0
- aac_invoke_auth/testing.py +170 -0
- aac_invoke_auth-0.1.0.dist-info/METADATA +147 -0
- aac_invoke_auth-0.1.0.dist-info/RECORD +9 -0
- aac_invoke_auth-0.1.0.dist-info/WHEEL +5 -0
- aac_invoke_auth-0.1.0.dist-info/licenses/LICENSE +177 -0
- aac_invoke_auth-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
"""Loopback ``/invoke`` request authentication (Backlog A1; Eng Spec §III.2.4a).
|
|
2
|
+
|
|
3
|
+
Since B82 PR-A (2026-07-09) this module is its own workspace member —
|
|
4
|
+
distribution ``aac-invoke-auth``, import package ``aac_invoke_auth`` —
|
|
5
|
+
moved out of ``aac-sdk`` so a tenant agent can install the verifier
|
|
6
|
+
without the SDK's dependency footprint (see Backlog B82/B87).
|
|
7
|
+
|
|
8
|
+
Threat model
|
|
9
|
+
------------
|
|
10
|
+
The sidecar POSTs verified chain context to the local agent's ``/invoke``
|
|
11
|
+
endpoint. Before A1, loopback bind-isolation WAS the security boundary:
|
|
12
|
+
any breach of that isolation (misconfigured container, host-networking
|
|
13
|
+
mode, compromised neighbor in the pod) let an attacker feed arbitrary
|
|
14
|
+
chain handles + payloads straight to the agent — bypassing ALL chain
|
|
15
|
+
verification, because the agent never verifies anything itself. This
|
|
16
|
+
module closes that gap: the sidecar signs every /invoke push with a
|
|
17
|
+
pairing secret shared with exactly one agent, and the agent rejects
|
|
18
|
+
requests that don't carry a valid, fresh signature.
|
|
19
|
+
|
|
20
|
+
Why HMAC (and not mTLS or JWS)
|
|
21
|
+
------------------------------
|
|
22
|
+
The agent is deliberately crypto-blind (AAC Design §0): no macaroon
|
|
23
|
+
bytes, no DPoP, no asymmetric crypto. A shared-secret HMAC keeps the
|
|
24
|
+
agent-side verifier at "standard library only" in every language —
|
|
25
|
+
which is what makes per-stack middleware ports mechanical (Backlog
|
|
26
|
+
B79). mTLS would TLS-ify the loopback hop and its deployment story;
|
|
27
|
+
JWS would drag a JOSE dependency into every agent stack.
|
|
28
|
+
|
|
29
|
+
Wire format (normative text lives in Eng Spec §III.2.4a)
|
|
30
|
+
--------------------------------------------------------
|
|
31
|
+
Two headers ride the /invoke request::
|
|
32
|
+
|
|
33
|
+
X-AAC-Invoke-Timestamp: <unix seconds, decimal>
|
|
34
|
+
X-AAC-Invoke-Signature: AAC1-HMAC-SHA256 <hex hmac-sha256>
|
|
35
|
+
|
|
36
|
+
The signature covers the string-to-sign::
|
|
37
|
+
|
|
38
|
+
AAC1-HMAC-SHA256 "\\n"
|
|
39
|
+
<HTTP method, uppercase> "\\n"
|
|
40
|
+
<URL path, no query/host> "\\n"
|
|
41
|
+
<timestamp, decimal> "\\n"
|
|
42
|
+
<sha256 of the raw body bytes, lowercase hex> "\\n"
|
|
43
|
+
<canonical X-AAC-* headers>
|
|
44
|
+
|
|
45
|
+
where the canonical header block is every header whose lowercase name
|
|
46
|
+
starts with ``x-aac-`` EXCEPT the two auth headers themselves, as
|
|
47
|
+
``name:value`` lines — names lowercased, values byte-exact (NO
|
|
48
|
+
whitespace normalization: the signature must authenticate exactly the
|
|
49
|
+
value the agent's framework hands to business logic, review finding
|
|
50
|
+
M1) — sorted by name and joined with ``\\n``. A repeated covered
|
|
51
|
+
header name is REJECTED outright: the paired sidecar never sends
|
|
52
|
+
duplicates, so a duplicate is either an attack or a broken proxy.
|
|
53
|
+
Deriving the covered set by RULE (prefix match) rather than a fixed
|
|
54
|
+
list means a request with any X-AAC-* header added, removed, or
|
|
55
|
+
altered after signing fails verification, including headers
|
|
56
|
+
introduced by future spec revisions.
|
|
57
|
+
|
|
58
|
+
Replay posture: freshness-window only (locked at A1 design time).
|
|
59
|
+
The threat A1 closes is forgery; a replayed message is one the sidecar
|
|
60
|
+
legitimately signed seconds earlier, so within-window replay adds
|
|
61
|
+
nothing against an idempotent /invoke. See Eng Spec §III.2.4a for the
|
|
62
|
+
upgrade path if a future deployment needs per-request replay detection.
|
|
63
|
+
|
|
64
|
+
The algorithm name is versioned (``AAC1-``) so a future scheme can ship
|
|
65
|
+
as ``AAC2-...`` and verifiers can reject unknown prefixes loudly —
|
|
66
|
+
mirroring the algorithm-agile root-signature convention (AAC Design §4.1).
|
|
67
|
+
"""
|
|
68
|
+
|
|
69
|
+
from __future__ import annotations
|
|
70
|
+
|
|
71
|
+
import hashlib
|
|
72
|
+
import hmac
|
|
73
|
+
import os
|
|
74
|
+
import time
|
|
75
|
+
from collections.abc import Mapping
|
|
76
|
+
from pathlib import Path
|
|
77
|
+
|
|
78
|
+
__all__ = [
|
|
79
|
+
"DEFAULT_FRESHNESS_WINDOW_SECONDS",
|
|
80
|
+
"INVOKE_AUTH_ALGORITHM",
|
|
81
|
+
"MIN_SECRET_LENGTH_BYTES",
|
|
82
|
+
"SECRET_FILE_ENV_VAR",
|
|
83
|
+
"SIGNATURE_HEADER",
|
|
84
|
+
"TIMESTAMP_HEADER",
|
|
85
|
+
"InvokeAuthError",
|
|
86
|
+
"InvokeSignatureMismatch",
|
|
87
|
+
"InvokeTimestampOutsideWindow",
|
|
88
|
+
"MalformedInvokeAuthHeader",
|
|
89
|
+
"MissingInvokeAuthHeader",
|
|
90
|
+
"WeakInvokeAuthSecret",
|
|
91
|
+
"build_string_to_sign",
|
|
92
|
+
"load_invoke_auth_secret",
|
|
93
|
+
"load_invoke_auth_secret_from_env",
|
|
94
|
+
"sign_invoke_request",
|
|
95
|
+
"verify_invoke_request",
|
|
96
|
+
]
|
|
97
|
+
|
|
98
|
+
INVOKE_AUTH_ALGORITHM = "AAC1-HMAC-SHA256"
|
|
99
|
+
SIGNATURE_HEADER = "X-AAC-Invoke-Signature"
|
|
100
|
+
TIMESTAMP_HEADER = "X-AAC-Invoke-Timestamp"
|
|
101
|
+
|
|
102
|
+
# ±30s tolerates realistic clock skew between two containers in the
|
|
103
|
+
# same pod/compose network while keeping the forged-replay window
|
|
104
|
+
# short. Locked at A1 design time (window-only, no nonce cache).
|
|
105
|
+
DEFAULT_FRESHNESS_WINDOW_SECONDS = 30
|
|
106
|
+
|
|
107
|
+
# 32 bytes ≈ 256 bits of secret material — matches the HMAC-SHA256
|
|
108
|
+
# block-security level. Shorter files are almost certainly a
|
|
109
|
+
# generation mistake (empty file, truncated mount), so fail loud.
|
|
110
|
+
MIN_SECRET_LENGTH_BYTES = 32
|
|
111
|
+
|
|
112
|
+
# Agents read their pairing secret path from this env var (compose /
|
|
113
|
+
# K8s sets it). The FILE-path indirection (rather than the secret
|
|
114
|
+
# itself in the env) keeps secrets out of `docker inspect` output.
|
|
115
|
+
SECRET_FILE_ENV_VAR = "AAC_INVOKE_AUTH_SECRET_FILE"
|
|
116
|
+
|
|
117
|
+
_COVERED_HEADER_PREFIX = "x-aac-"
|
|
118
|
+
_AUTH_HEADER_NAMES_LOWER = frozenset(
|
|
119
|
+
{SIGNATURE_HEADER.lower(), TIMESTAMP_HEADER.lower()}
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
class InvokeAuthError(Exception):
|
|
124
|
+
"""Base for every /invoke authentication failure.
|
|
125
|
+
|
|
126
|
+
Deliberately module-local (not in ``aac.exceptions``): the
|
|
127
|
+
exception family is part of the self-contained surface a B79
|
|
128
|
+
middleware port re-implements, so it lives with the algorithm.
|
|
129
|
+
"""
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
class MissingInvokeAuthHeader(InvokeAuthError):
|
|
133
|
+
"""The request carries no signature and/or no timestamp header."""
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
class MalformedInvokeAuthHeader(InvokeAuthError):
|
|
137
|
+
"""A header is present but unparseable (bad shape, unknown
|
|
138
|
+
algorithm prefix, non-integer timestamp)."""
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
class InvokeTimestampOutsideWindow(InvokeAuthError):
|
|
142
|
+
"""The timestamp is valid but outside the freshness window."""
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
class InvokeSignatureMismatch(InvokeAuthError):
|
|
146
|
+
"""The recomputed HMAC does not match the presented signature —
|
|
147
|
+
the request was tampered with, signed with a different secret,
|
|
148
|
+
or canonicalized differently by the two sides."""
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
class WeakInvokeAuthSecret(InvokeAuthError):
|
|
152
|
+
"""The secret file's content is too short to be a real secret."""
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
def load_invoke_auth_secret(path: str | Path) -> bytes:
|
|
156
|
+
"""Read a pairing secret from ``path``.
|
|
157
|
+
|
|
158
|
+
The secret is the file's content with surrounding whitespace
|
|
159
|
+
stripped, treated as opaque bytes — no hex/base64 decoding, so a
|
|
160
|
+
B79 port never has to guess the encoding. Recommended generation:
|
|
161
|
+
``openssl rand -hex 32`` (yields 64 bytes of hex text on disk).
|
|
162
|
+
"""
|
|
163
|
+
secret = Path(path).read_bytes().strip()
|
|
164
|
+
if len(secret) < MIN_SECRET_LENGTH_BYTES:
|
|
165
|
+
raise WeakInvokeAuthSecret(
|
|
166
|
+
f"invoke-auth secret at {path} is {len(secret)} bytes after "
|
|
167
|
+
f"whitespace strip; at least {MIN_SECRET_LENGTH_BYTES} are "
|
|
168
|
+
f"required. Generate one with: openssl rand -hex 32"
|
|
169
|
+
)
|
|
170
|
+
return secret
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
def load_invoke_auth_secret_from_env(
|
|
174
|
+
env_var: str = SECRET_FILE_ENV_VAR,
|
|
175
|
+
) -> bytes | None:
|
|
176
|
+
"""Low-level helper: load the secret named by ``env_var``.
|
|
177
|
+
|
|
178
|
+
Returns None when the env var is unset/empty; a set-but-unreadable
|
|
179
|
+
path raises — a deployment that CONFIGURED auth and got it wrong
|
|
180
|
+
must fail loud, not silently open up.
|
|
181
|
+
|
|
182
|
+
NOTE (B82 PR-B): returning None is NOT a license to run
|
|
183
|
+
unauthenticated. Policy lives one layer up — the FastAPI guard's
|
|
184
|
+
:meth:`~aac_invoke_auth.fastapi.InvokeAuthGuard.from_env` fails
|
|
185
|
+
fast at startup on a None here unless
|
|
186
|
+
``AAC_INVOKE_AUTH_ALLOW_UNAUTHENTICATED=true`` was set explicitly.
|
|
187
|
+
A B79 middleware port for another stack must implement the same
|
|
188
|
+
interlock.
|
|
189
|
+
"""
|
|
190
|
+
secret_path = os.environ.get(env_var, "").strip()
|
|
191
|
+
if not secret_path:
|
|
192
|
+
return None
|
|
193
|
+
return load_invoke_auth_secret(secret_path)
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
def _canonical_header_block(headers: Mapping[str, str]) -> str:
|
|
197
|
+
"""Build the canonical X-AAC-* header block (see module docstring).
|
|
198
|
+
|
|
199
|
+
Accepts any str→str mapping (a plain dict on the signing side; a
|
|
200
|
+
Starlette ``Headers`` object — whose ``.items()`` yields one entry
|
|
201
|
+
per raw header line — on the verify side). Values enter the block
|
|
202
|
+
BYTE-EXACT: any normalization here would let an attacker mutate
|
|
203
|
+
the raw value the agent's framework actually delivers without
|
|
204
|
+
breaking the signature (review finding M1). A repeated covered
|
|
205
|
+
name is rejected for the same reason — Starlette's ``get()``
|
|
206
|
+
returns only the first value, so a smuggled duplicate would
|
|
207
|
+
diverge from what business logic sees.
|
|
208
|
+
"""
|
|
209
|
+
collected: dict[str, str] = {}
|
|
210
|
+
for name, value in headers.items():
|
|
211
|
+
lname = name.lower()
|
|
212
|
+
if not lname.startswith(_COVERED_HEADER_PREFIX):
|
|
213
|
+
continue
|
|
214
|
+
if lname in _AUTH_HEADER_NAMES_LOWER:
|
|
215
|
+
continue
|
|
216
|
+
if lname in collected:
|
|
217
|
+
raise MalformedInvokeAuthHeader(
|
|
218
|
+
f"covered header {lname!r} appears more than once — the "
|
|
219
|
+
f"paired sidecar never sends duplicate X-AAC-* headers, "
|
|
220
|
+
f"so a duplicate is rejected rather than canonicalized"
|
|
221
|
+
)
|
|
222
|
+
collected[lname] = value
|
|
223
|
+
lines = [f"{lname}:{value}" for lname, value in sorted(collected.items())]
|
|
224
|
+
return "\n".join(lines)
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
def build_string_to_sign(
|
|
228
|
+
*,
|
|
229
|
+
method: str,
|
|
230
|
+
path: str,
|
|
231
|
+
timestamp: int,
|
|
232
|
+
body: bytes,
|
|
233
|
+
headers: Mapping[str, str],
|
|
234
|
+
) -> str:
|
|
235
|
+
"""Assemble the exact string both sides HMAC. Public so tests and
|
|
236
|
+
B79 ports can compare against the spec's known-answer vectors."""
|
|
237
|
+
body_sha256_hex = hashlib.sha256(body).hexdigest()
|
|
238
|
+
return "\n".join(
|
|
239
|
+
[
|
|
240
|
+
INVOKE_AUTH_ALGORITHM,
|
|
241
|
+
method.upper(),
|
|
242
|
+
path,
|
|
243
|
+
str(timestamp),
|
|
244
|
+
body_sha256_hex,
|
|
245
|
+
_canonical_header_block(headers),
|
|
246
|
+
]
|
|
247
|
+
)
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
def _compute_signature_hex(
|
|
251
|
+
*,
|
|
252
|
+
secret: bytes,
|
|
253
|
+
method: str,
|
|
254
|
+
path: str,
|
|
255
|
+
timestamp: int,
|
|
256
|
+
body: bytes,
|
|
257
|
+
headers: Mapping[str, str],
|
|
258
|
+
) -> str:
|
|
259
|
+
string_to_sign = build_string_to_sign(
|
|
260
|
+
method=method, path=path, timestamp=timestamp, body=body, headers=headers
|
|
261
|
+
)
|
|
262
|
+
return hmac.new(secret, string_to_sign.encode("utf-8"), hashlib.sha256).hexdigest()
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
def sign_invoke_request(
|
|
266
|
+
*,
|
|
267
|
+
secret: bytes,
|
|
268
|
+
method: str,
|
|
269
|
+
path: str,
|
|
270
|
+
headers: Mapping[str, str],
|
|
271
|
+
body: bytes,
|
|
272
|
+
timestamp: int | None = None,
|
|
273
|
+
) -> dict[str, str]:
|
|
274
|
+
"""Sidecar side: produce the two auth headers for an /invoke push.
|
|
275
|
+
|
|
276
|
+
``headers`` is the outbound header dict as it will be sent (the
|
|
277
|
+
covered X-AAC-* subset is filtered out by rule here, so passing
|
|
278
|
+
Content-Type etc. is fine). Merge the returned dict into the
|
|
279
|
+
outbound headers AFTER every X-AAC-* header is final — a header
|
|
280
|
+
added after signing will fail verification on the agent side,
|
|
281
|
+
by design.
|
|
282
|
+
"""
|
|
283
|
+
ts = int(time.time()) if timestamp is None else timestamp
|
|
284
|
+
signature_hex = _compute_signature_hex(
|
|
285
|
+
secret=secret, method=method, path=path, timestamp=ts, body=body, headers=headers
|
|
286
|
+
)
|
|
287
|
+
return {
|
|
288
|
+
TIMESTAMP_HEADER: str(ts),
|
|
289
|
+
SIGNATURE_HEADER: f"{INVOKE_AUTH_ALGORITHM} {signature_hex}",
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
def verify_invoke_request(
|
|
294
|
+
*,
|
|
295
|
+
secret: bytes,
|
|
296
|
+
method: str,
|
|
297
|
+
path: str,
|
|
298
|
+
headers: Mapping[str, str],
|
|
299
|
+
body: bytes,
|
|
300
|
+
now: int | None = None,
|
|
301
|
+
freshness_window_seconds: int = DEFAULT_FRESHNESS_WINDOW_SECONDS,
|
|
302
|
+
) -> None:
|
|
303
|
+
"""Agent side: verify an inbound /invoke request or raise.
|
|
304
|
+
|
|
305
|
+
Raises a specific :class:`InvokeAuthError` subclass on failure;
|
|
306
|
+
returns None on success. ``headers`` should be the FULL inbound
|
|
307
|
+
header mapping (e.g. Starlette's ``request.headers``) — the
|
|
308
|
+
covered set is re-derived by rule from what was actually
|
|
309
|
+
received, so header insertion/removal after signing is caught.
|
|
310
|
+
"""
|
|
311
|
+
signature_value = _get_single_header(headers, SIGNATURE_HEADER)
|
|
312
|
+
timestamp_value = _get_single_header(headers, TIMESTAMP_HEADER)
|
|
313
|
+
if signature_value is None or timestamp_value is None:
|
|
314
|
+
raise MissingInvokeAuthHeader(
|
|
315
|
+
f"/invoke request is missing {SIGNATURE_HEADER} and/or "
|
|
316
|
+
f"{TIMESTAMP_HEADER} — the paired sidecar signs every push "
|
|
317
|
+
f"(Eng Spec §III.2.4a); an unsigned request did not come "
|
|
318
|
+
f"from it"
|
|
319
|
+
)
|
|
320
|
+
|
|
321
|
+
algorithm, _, presented_hex = signature_value.strip().partition(" ")
|
|
322
|
+
if algorithm != INVOKE_AUTH_ALGORITHM or not presented_hex:
|
|
323
|
+
raise MalformedInvokeAuthHeader(
|
|
324
|
+
f"{SIGNATURE_HEADER} must be '{INVOKE_AUTH_ALGORITHM} <hex>'; "
|
|
325
|
+
f"got algorithm {algorithm!r}. Unknown algorithms are "
|
|
326
|
+
f"rejected rather than ignored (versioned-prefix agility)"
|
|
327
|
+
)
|
|
328
|
+
|
|
329
|
+
try:
|
|
330
|
+
ts = int(timestamp_value.strip())
|
|
331
|
+
except ValueError:
|
|
332
|
+
raise MalformedInvokeAuthHeader(
|
|
333
|
+
f"{TIMESTAMP_HEADER} must be decimal unix seconds; "
|
|
334
|
+
f"got {timestamp_value!r}"
|
|
335
|
+
) from None
|
|
336
|
+
|
|
337
|
+
current = int(time.time()) if now is None else now
|
|
338
|
+
if abs(current - ts) > freshness_window_seconds:
|
|
339
|
+
raise InvokeTimestampOutsideWindow(
|
|
340
|
+
f"/invoke signature timestamp {ts} is {abs(current - ts)}s from "
|
|
341
|
+
f"now ({current}); window is ±{freshness_window_seconds}s. "
|
|
342
|
+
f"Check for clock skew between sidecar and agent containers"
|
|
343
|
+
)
|
|
344
|
+
|
|
345
|
+
expected_hex = _compute_signature_hex(
|
|
346
|
+
secret=secret, method=method, path=path, timestamp=ts, body=body, headers=headers
|
|
347
|
+
)
|
|
348
|
+
# hmac.compare_digest — constant-time compare; a plain `==` would
|
|
349
|
+
# leak match-prefix length through timing.
|
|
350
|
+
if not hmac.compare_digest(expected_hex, presented_hex.strip()):
|
|
351
|
+
raise InvokeSignatureMismatch(
|
|
352
|
+
"/invoke signature mismatch — the request was altered after "
|
|
353
|
+
"signing, signed with a different pairing secret, or the two "
|
|
354
|
+
"sides disagree on the canonical string (method/path/body/"
|
|
355
|
+
"X-AAC-* headers). See Eng Spec §III.2.4a for the "
|
|
356
|
+
"canonicalization rules"
|
|
357
|
+
)
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
def _get_single_header(headers: Mapping[str, str], name: str) -> str | None:
|
|
361
|
+
"""Case-insensitive single-header lookup over a plain dict or a
|
|
362
|
+
Starlette Headers object (whose ``get`` is already case-insensitive,
|
|
363
|
+
but a plain dict's is not — tests use plain dicts)."""
|
|
364
|
+
lname = name.lower()
|
|
365
|
+
for key, value in headers.items():
|
|
366
|
+
if key.lower() == lname:
|
|
367
|
+
return value
|
|
368
|
+
return None
|
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
"""FastAPI/Starlette mounting surfaces for invoke-push verification (B82).
|
|
2
|
+
|
|
3
|
+
This submodule is the first per-stack middleware port of the B79
|
|
4
|
+
delivery model: ``pip install aac-invoke-auth[fastapi]`` gives a tenant
|
|
5
|
+
agent two one-line ways to authenticate ``/invoke`` pushes from its
|
|
6
|
+
paired AAC sidecar, wrapping the frozen AAC1-HMAC-SHA256 core in
|
|
7
|
+
:mod:`aac_invoke_auth` (which stays importable without FastAPI — this
|
|
8
|
+
submodule is deliberately NOT imported from the package ``__init__``).
|
|
9
|
+
|
|
10
|
+
Two mounting surfaces, one verifier underneath
|
|
11
|
+
----------------------------------------------
|
|
12
|
+
* Route-scoped dependency::
|
|
13
|
+
|
|
14
|
+
guard = InvokeAuthGuard.from_env()
|
|
15
|
+
|
|
16
|
+
@app.post("/invoke", dependencies=[Depends(guard)])
|
|
17
|
+
async def invoke(request: Request): ...
|
|
18
|
+
|
|
19
|
+
* App-level middleware with a REQUIRED path filter (protect ``/invoke``
|
|
20
|
+
only; health probes and tenant business routes stay untouched)::
|
|
21
|
+
|
|
22
|
+
app.add_middleware(
|
|
23
|
+
InvokeAuthMiddleware,
|
|
24
|
+
guard=InvokeAuthGuard.from_env(),
|
|
25
|
+
protected_paths=("/invoke",),
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
Both read the raw body bytes BEFORE verification and hand them back to
|
|
29
|
+
the application afterwards, so a downstream ``await request.json()``
|
|
30
|
+
works unchanged (the dependency relies on Starlette's request-body
|
|
31
|
+
cache; the middleware replays the buffered receive stream).
|
|
32
|
+
|
|
33
|
+
Fail-fast startup interlock (supersedes the A1 "unset = dev-only
|
|
34
|
+
unauthenticated posture")
|
|
35
|
+
--------------------------------------------------------------------
|
|
36
|
+
:meth:`InvokeAuthGuard.from_env` REFUSES to construct when
|
|
37
|
+
``AAC_INVOKE_AUTH_SECRET_FILE`` is unset — a missing secret on a
|
|
38
|
+
tenant install is a security downgrade that must fail the process at
|
|
39
|
+
startup, not degrade into a warning nobody reads. The single escape
|
|
40
|
+
hatch is setting ``AAC_INVOKE_AUTH_ALLOW_UNAUTHENTICATED=true``
|
|
41
|
+
explicitly (symmetric with the sidecar's ``dev_mode`` interlock, which
|
|
42
|
+
gates the signing side of the same pair). It exists for extraordinary
|
|
43
|
+
cases only — tenant test/pilot environments, debugging a suspected
|
|
44
|
+
canonicalization mismatch — and an opted-out guard logs a prominent
|
|
45
|
+
warning at construction so the posture is loud in the logs, never
|
|
46
|
+
silent. See Eng Spec §III.2.4a and this package's README.
|
|
47
|
+
"""
|
|
48
|
+
|
|
49
|
+
from __future__ import annotations
|
|
50
|
+
|
|
51
|
+
import logging
|
|
52
|
+
import os
|
|
53
|
+
from collections.abc import Iterable
|
|
54
|
+
|
|
55
|
+
from fastapi import HTTPException, Request
|
|
56
|
+
from starlette.datastructures import Headers
|
|
57
|
+
from starlette.responses import JSONResponse
|
|
58
|
+
from starlette.types import ASGIApp, Message, Receive, Scope, Send
|
|
59
|
+
|
|
60
|
+
from aac_invoke_auth import (
|
|
61
|
+
DEFAULT_FRESHNESS_WINDOW_SECONDS,
|
|
62
|
+
InvokeAuthError,
|
|
63
|
+
load_invoke_auth_secret_from_env,
|
|
64
|
+
verify_invoke_request,
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
__all__ = [
|
|
68
|
+
"ALLOW_UNAUTHENTICATED_ENV_VAR",
|
|
69
|
+
"InvokeAuthConfigurationError",
|
|
70
|
+
"InvokeAuthGuard",
|
|
71
|
+
"InvokeAuthMiddleware",
|
|
72
|
+
]
|
|
73
|
+
|
|
74
|
+
logger = logging.getLogger("aac_invoke_auth.fastapi")
|
|
75
|
+
|
|
76
|
+
# The explicit opt-out for the fail-fast interlock. Only the exact
|
|
77
|
+
# value "true" (case-insensitive) opts out — "1"/"yes"/typos do NOT,
|
|
78
|
+
# so a mangled deployment manifest fails loud instead of silently
|
|
79
|
+
# disabling authentication.
|
|
80
|
+
ALLOW_UNAUTHENTICATED_ENV_VAR = "AAC_INVOKE_AUTH_ALLOW_UNAUTHENTICATED"
|
|
81
|
+
|
|
82
|
+
# One generic wire detail for every rejection (A1 review finding S1):
|
|
83
|
+
# the specific failure class goes to the agent's log only, denying a
|
|
84
|
+
# probing attacker a free failure oracle.
|
|
85
|
+
_REJECTION_DETAIL = "invoke auth failed"
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def _route_path(scope: Scope) -> str:
|
|
89
|
+
"""The router's view of the request path: ``scope["path"]`` with the
|
|
90
|
+
ASGI ``root_path`` prefix stripped (same rule Starlette's routing
|
|
91
|
+
applies). BOTH surfaces filter and verify on this value (pre-PR
|
|
92
|
+
review H1/H2): matching on the raw ``scope["path"]`` would let a
|
|
93
|
+
``root_path``/Mount deployment sail PAST an exact-match filter —
|
|
94
|
+
a fail-open — while the route it reaches is still ``/invoke``.
|
|
95
|
+
Consequence for signers: the paired sidecar signs the path as the
|
|
96
|
+
agent APP sees it (pairs share a pod; a prefix-rewriting proxy
|
|
97
|
+
between sidecar and agent breaks the signature by design).
|
|
98
|
+
"""
|
|
99
|
+
root_path: str = scope.get("root_path", "")
|
|
100
|
+
path: str = scope["path"]
|
|
101
|
+
if root_path and path.startswith(root_path):
|
|
102
|
+
return path[len(root_path):]
|
|
103
|
+
return path
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
class InvokeAuthConfigurationError(InvokeAuthError):
|
|
107
|
+
"""Startup-time misconfiguration: no pairing secret and no explicit
|
|
108
|
+
unauthenticated opt-out. Raised by :meth:`InvokeAuthGuard.from_env`
|
|
109
|
+
BEFORE the app serves a single request — the fail-fast half of the
|
|
110
|
+
interlock whose signing half is the sidecar's ``dev_mode`` gate."""
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
class InvokeAuthGuard:
|
|
114
|
+
"""Verifies ``/invoke`` pushes against the pairing secret.
|
|
115
|
+
|
|
116
|
+
Construct directly with secret bytes (e.g. from a secret manager),
|
|
117
|
+
or via :meth:`from_env` which reads ``AAC_INVOKE_AUTH_SECRET_FILE``
|
|
118
|
+
and enforces the fail-fast interlock. The instance is itself a
|
|
119
|
+
FastAPI dependency — mount with ``Depends(guard)`` — and is the
|
|
120
|
+
``guard=`` argument :class:`InvokeAuthMiddleware` requires. Both
|
|
121
|
+
surfaces call :meth:`verify_request`, so behavior cannot drift
|
|
122
|
+
between them.
|
|
123
|
+
"""
|
|
124
|
+
|
|
125
|
+
def __init__(
|
|
126
|
+
self,
|
|
127
|
+
secret: bytes,
|
|
128
|
+
*,
|
|
129
|
+
freshness_window_seconds: int = DEFAULT_FRESHNESS_WINDOW_SECONDS,
|
|
130
|
+
) -> None:
|
|
131
|
+
if not secret:
|
|
132
|
+
# Empty bytes here is always a wiring bug — the explicit
|
|
133
|
+
# unauthenticated posture goes through from_env()'s opt-out
|
|
134
|
+
# (or _unauthenticated()), never through a falsy secret.
|
|
135
|
+
raise InvokeAuthConfigurationError(
|
|
136
|
+
"InvokeAuthGuard requires non-empty secret bytes; for an "
|
|
137
|
+
f"explicitly unauthenticated guard set "
|
|
138
|
+
f"{ALLOW_UNAUTHENTICATED_ENV_VAR}=true and use from_env()"
|
|
139
|
+
)
|
|
140
|
+
self._init_fields(secret, freshness_window_seconds)
|
|
141
|
+
|
|
142
|
+
def _init_fields(
|
|
143
|
+
self, secret: bytes | None, freshness_window_seconds: int
|
|
144
|
+
) -> None:
|
|
145
|
+
"""THE single place instance fields are assigned — __init__ and
|
|
146
|
+
_unauthenticated() both delegate here, so a future field can't
|
|
147
|
+
be set on one construction path and missed on the other
|
|
148
|
+
(pre-PR review S5)."""
|
|
149
|
+
self._secret: bytes | None = secret
|
|
150
|
+
self._freshness_window_seconds = freshness_window_seconds
|
|
151
|
+
|
|
152
|
+
@classmethod
|
|
153
|
+
def _unauthenticated(
|
|
154
|
+
cls,
|
|
155
|
+
*,
|
|
156
|
+
freshness_window_seconds: int = DEFAULT_FRESHNESS_WINDOW_SECONDS,
|
|
157
|
+
) -> InvokeAuthGuard:
|
|
158
|
+
"""Internal: build a passthrough guard (explicit opt-out only)."""
|
|
159
|
+
guard = cls.__new__(cls)
|
|
160
|
+
guard._init_fields(None, freshness_window_seconds)
|
|
161
|
+
logger.warning(
|
|
162
|
+
"invoke-push authentication is DISABLED (%s=true): every "
|
|
163
|
+
"/invoke request will be accepted WITHOUT verifying it came "
|
|
164
|
+
"from the paired sidecar. This posture is for tenant "
|
|
165
|
+
"test/pilot debugging only — never production",
|
|
166
|
+
ALLOW_UNAUTHENTICATED_ENV_VAR,
|
|
167
|
+
)
|
|
168
|
+
return guard
|
|
169
|
+
|
|
170
|
+
@classmethod
|
|
171
|
+
def from_env(
|
|
172
|
+
cls,
|
|
173
|
+
*,
|
|
174
|
+
freshness_window_seconds: int = DEFAULT_FRESHNESS_WINDOW_SECONDS,
|
|
175
|
+
) -> InvokeAuthGuard:
|
|
176
|
+
"""Build a guard from the environment, failing fast at startup.
|
|
177
|
+
|
|
178
|
+
Resolution order:
|
|
179
|
+
|
|
180
|
+
* ``AAC_INVOKE_AUTH_SECRET_FILE`` set → load the secret from
|
|
181
|
+
that file (unreadable/too-short files raise, per the core's
|
|
182
|
+
fail-loud contract). A configured secret ALWAYS wins — the
|
|
183
|
+
opt-out var is ignored (with a log line) when both are set.
|
|
184
|
+
* unset, ``AAC_INVOKE_AUTH_ALLOW_UNAUTHENTICATED=true`` →
|
|
185
|
+
explicitly unauthenticated passthrough guard (prominent
|
|
186
|
+
warning logged).
|
|
187
|
+
* unset, no opt-out → :class:`InvokeAuthConfigurationError`.
|
|
188
|
+
The process must not come up half-secured by accident.
|
|
189
|
+
"""
|
|
190
|
+
secret = load_invoke_auth_secret_from_env()
|
|
191
|
+
opt_out_value = os.environ.get(ALLOW_UNAUTHENTICATED_ENV_VAR, "")
|
|
192
|
+
opted_out = opt_out_value.strip().lower() == "true"
|
|
193
|
+
if secret is not None:
|
|
194
|
+
if opted_out:
|
|
195
|
+
logger.info(
|
|
196
|
+
"%s=true is ignored because a pairing secret is "
|
|
197
|
+
"configured — running authenticated",
|
|
198
|
+
ALLOW_UNAUTHENTICATED_ENV_VAR,
|
|
199
|
+
)
|
|
200
|
+
return cls(
|
|
201
|
+
secret, freshness_window_seconds=freshness_window_seconds
|
|
202
|
+
)
|
|
203
|
+
if opted_out:
|
|
204
|
+
return cls._unauthenticated(
|
|
205
|
+
freshness_window_seconds=freshness_window_seconds
|
|
206
|
+
)
|
|
207
|
+
raise InvokeAuthConfigurationError(
|
|
208
|
+
"no invoke-auth pairing secret configured: set "
|
|
209
|
+
"AAC_INVOKE_AUTH_SECRET_FILE to the secret file shared with "
|
|
210
|
+
"the paired sidecar (generate with: openssl rand -hex 32). "
|
|
211
|
+
f"To run UNAUTHENTICATED (tenant test/pilot debugging only) "
|
|
212
|
+
f"set {ALLOW_UNAUTHENTICATED_ENV_VAR}=true explicitly. "
|
|
213
|
+
"Refusing to start half-secured (Eng Spec §III.2.4a)"
|
|
214
|
+
)
|
|
215
|
+
|
|
216
|
+
@property
|
|
217
|
+
def authenticated(self) -> bool:
|
|
218
|
+
"""False only for an explicitly opted-out passthrough guard."""
|
|
219
|
+
return self._secret is not None
|
|
220
|
+
|
|
221
|
+
def verify_request(
|
|
222
|
+
self,
|
|
223
|
+
*,
|
|
224
|
+
method: str,
|
|
225
|
+
path: str,
|
|
226
|
+
headers: Headers,
|
|
227
|
+
body: bytes,
|
|
228
|
+
) -> None:
|
|
229
|
+
"""Verify one request or raise :class:`InvokeAuthError`.
|
|
230
|
+
|
|
231
|
+
The single verifier both mounting surfaces call. Passthrough
|
|
232
|
+
(opted-out) guards return immediately — the loud warning
|
|
233
|
+
already fired at construction.
|
|
234
|
+
"""
|
|
235
|
+
if self._secret is None:
|
|
236
|
+
return
|
|
237
|
+
verify_invoke_request(
|
|
238
|
+
secret=self._secret,
|
|
239
|
+
method=method,
|
|
240
|
+
path=path,
|
|
241
|
+
headers=headers,
|
|
242
|
+
body=body,
|
|
243
|
+
freshness_window_seconds=self._freshness_window_seconds,
|
|
244
|
+
)
|
|
245
|
+
|
|
246
|
+
async def __call__(self, request: Request) -> None:
|
|
247
|
+
"""FastAPI dependency surface: ``Depends(guard)``.
|
|
248
|
+
|
|
249
|
+
Reads the raw body BEFORE verification — Starlette caches it on
|
|
250
|
+
the request, so the route handler's own ``await request.body()``
|
|
251
|
+
/ ``await request.json()`` sees the same bytes (the bofa-agent
|
|
252
|
+
A1 handler established this ordering as the precedent).
|
|
253
|
+
"""
|
|
254
|
+
body_bytes = await request.body()
|
|
255
|
+
try:
|
|
256
|
+
self.verify_request(
|
|
257
|
+
method=request.method,
|
|
258
|
+
path=_route_path(request.scope),
|
|
259
|
+
headers=request.headers,
|
|
260
|
+
body=body_bytes,
|
|
261
|
+
)
|
|
262
|
+
except InvokeAuthError as e:
|
|
263
|
+
# 401, not a refuse() decision: a bad signature is a
|
|
264
|
+
# transport-trust failure, not a business refusal — the
|
|
265
|
+
# sidecar surfaces it as ERR_AGENT_REJECTED and an attacker
|
|
266
|
+
# gets no AgentDecision surface at all.
|
|
267
|
+
logger.warning("rejecting /invoke push: %s", e)
|
|
268
|
+
raise HTTPException(
|
|
269
|
+
status_code=401, detail=_REJECTION_DETAIL
|
|
270
|
+
) from e
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
class InvokeAuthMiddleware:
|
|
274
|
+
"""Pure-ASGI middleware surface: one ``add_middleware`` line.
|
|
275
|
+
|
|
276
|
+
``protected_paths`` is REQUIRED and exact-match: only those paths
|
|
277
|
+
are verified, so health probes and tenant business routes never
|
|
278
|
+
pay the buffering cost (nor break when unsigned). For anything
|
|
279
|
+
fancier than exact paths, mount ``Depends(guard)`` on the routes
|
|
280
|
+
instead.
|
|
281
|
+
|
|
282
|
+
Implemented against the raw ASGI protocol (not BaseHTTPMiddleware):
|
|
283
|
+
the request body is buffered message-by-message, verified, then the
|
|
284
|
+
buffered stream is replayed to the downstream app — so handlers
|
|
285
|
+
read the body exactly as if the middleware weren't there.
|
|
286
|
+
"""
|
|
287
|
+
|
|
288
|
+
def __init__(
|
|
289
|
+
self,
|
|
290
|
+
app: ASGIApp,
|
|
291
|
+
*,
|
|
292
|
+
guard: InvokeAuthGuard,
|
|
293
|
+
protected_paths: Iterable[str],
|
|
294
|
+
) -> None:
|
|
295
|
+
self._app = app
|
|
296
|
+
self._guard = guard
|
|
297
|
+
if isinstance(protected_paths, str):
|
|
298
|
+
# A bare string IS an Iterable[str] — frozenset("/invoke")
|
|
299
|
+
# would silently become per-character "paths" and protect
|
|
300
|
+
# nothing (pre-PR review M3). Fail loud instead.
|
|
301
|
+
raise InvokeAuthConfigurationError(
|
|
302
|
+
"protected_paths must be an iterable of paths, not a "
|
|
303
|
+
f'bare string — write protected_paths=("{protected_paths}",)'
|
|
304
|
+
)
|
|
305
|
+
self._protected_paths = frozenset(protected_paths)
|
|
306
|
+
if not self._protected_paths:
|
|
307
|
+
raise InvokeAuthConfigurationError(
|
|
308
|
+
"InvokeAuthMiddleware requires at least one protected "
|
|
309
|
+
'path (e.g. protected_paths=("/invoke",)) — an empty '
|
|
310
|
+
"filter would verify nothing while looking mounted"
|
|
311
|
+
)
|
|
312
|
+
|
|
313
|
+
async def __call__(
|
|
314
|
+
self, scope: Scope, receive: Receive, send: Send
|
|
315
|
+
) -> None:
|
|
316
|
+
if scope["type"] != "http":
|
|
317
|
+
await self._app(scope, receive, send)
|
|
318
|
+
return
|
|
319
|
+
route_path = _route_path(scope)
|
|
320
|
+
if route_path not in self._protected_paths:
|
|
321
|
+
await self._app(scope, receive, send)
|
|
322
|
+
return
|
|
323
|
+
|
|
324
|
+
# Buffer the full request body. The paired sidecar sends small
|
|
325
|
+
# JSON envelopes (size caps tracked as Backlog B76), and the
|
|
326
|
+
# signature covers the body digest, so the whole body is needed
|
|
327
|
+
# before any verdict.
|
|
328
|
+
messages: list[Message] = []
|
|
329
|
+
body = b""
|
|
330
|
+
while True:
|
|
331
|
+
message = await receive()
|
|
332
|
+
messages.append(message)
|
|
333
|
+
if message["type"] == "http.disconnect":
|
|
334
|
+
break
|
|
335
|
+
body += message.get("body", b"")
|
|
336
|
+
if not message.get("more_body", False):
|
|
337
|
+
break
|
|
338
|
+
|
|
339
|
+
try:
|
|
340
|
+
self._guard.verify_request(
|
|
341
|
+
method=scope["method"],
|
|
342
|
+
path=route_path,
|
|
343
|
+
headers=Headers(scope=scope),
|
|
344
|
+
body=body,
|
|
345
|
+
)
|
|
346
|
+
except InvokeAuthError as e:
|
|
347
|
+
logger.warning("rejecting /invoke push: %s", e)
|
|
348
|
+
# Same envelope FastAPI's default HTTPException handler
|
|
349
|
+
# produces, so with default error handling the two mounting
|
|
350
|
+
# surfaces answer identically on the wire. Caveat (pre-PR
|
|
351
|
+
# review M4): this response is emitted OUTSIDE the app's
|
|
352
|
+
# exception-handler/middleware stack — an app that
|
|
353
|
+
# customizes 401 rendering (or stamps headers via other
|
|
354
|
+
# middleware) will see the Depends surface follow the
|
|
355
|
+
# customization while this one does not.
|
|
356
|
+
response = JSONResponse(
|
|
357
|
+
{"detail": _REJECTION_DETAIL}, status_code=401
|
|
358
|
+
)
|
|
359
|
+
await response(scope, receive, send)
|
|
360
|
+
return
|
|
361
|
+
|
|
362
|
+
replay = iter(messages)
|
|
363
|
+
|
|
364
|
+
async def replay_receive() -> Message:
|
|
365
|
+
for buffered in replay:
|
|
366
|
+
return buffered
|
|
367
|
+
return await receive()
|
|
368
|
+
|
|
369
|
+
await self._app(scope, replay_receive, send)
|
aac_invoke_auth/py.typed
ADDED
|
File without changes
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
"""Test scaffold for agents behind invoke-push authentication (B82).
|
|
2
|
+
|
|
3
|
+
Library-grade helper in the ``aac.tenant_siem.testing`` /
|
|
4
|
+
``pandas.testing`` convention: agent test suites import from here
|
|
5
|
+
instead of copy-pasting a signing helper 11 times.
|
|
6
|
+
|
|
7
|
+
Since B82 PR-B the reference agents mount :class:`~aac_invoke_auth.
|
|
8
|
+
fastapi.InvokeAuthMiddleware` at import time, and the repo-root
|
|
9
|
+
``conftest.py`` pins ``AAC_INVOKE_AUTH_SECRET_FILE`` to a generated
|
|
10
|
+
secret file BEFORE any agent module is imported — so every agent test
|
|
11
|
+
runs fully authenticated (no test-only opt-out; the production code
|
|
12
|
+
path is what gets exercised). :func:`signed_invoke_post` signs a test
|
|
13
|
+
request with that same env-configured secret, exactly like the paired
|
|
14
|
+
sidecar would.
|
|
15
|
+
|
|
16
|
+
Std-lib + core only: no FastAPI import, so this module works for any
|
|
17
|
+
httpx-compatible test client.
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
from __future__ import annotations
|
|
21
|
+
|
|
22
|
+
import json
|
|
23
|
+
from typing import Any, Protocol
|
|
24
|
+
|
|
25
|
+
from aac_invoke_auth import (
|
|
26
|
+
load_invoke_auth_secret_from_env,
|
|
27
|
+
sign_invoke_request,
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
__all__ = [
|
|
31
|
+
"InvokeSigningClient",
|
|
32
|
+
"signed_invoke_post",
|
|
33
|
+
"signing_test_client",
|
|
34
|
+
]
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class _PostableClient(Protocol):
|
|
38
|
+
"""The slice of TestClient/httpx.Client the helpers need. Kwargs
|
|
39
|
+
stay open (headers=/json=/content=/...) so both the signing path
|
|
40
|
+
and the passthrough path type-check against real clients."""
|
|
41
|
+
|
|
42
|
+
def post(
|
|
43
|
+
self, url: str, **kwargs: Any
|
|
44
|
+
) -> Any: ... # pragma: no cover - typing only
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def signed_invoke_post(
|
|
48
|
+
client: _PostableClient,
|
|
49
|
+
*,
|
|
50
|
+
headers: dict[str, str],
|
|
51
|
+
json_payload: Any | None = None,
|
|
52
|
+
content: bytes | None = None,
|
|
53
|
+
path: str = "/invoke",
|
|
54
|
+
secret: bytes | None = None,
|
|
55
|
+
) -> Any:
|
|
56
|
+
"""POST a signed request the way the paired sidecar would.
|
|
57
|
+
|
|
58
|
+
Exactly one of ``json_payload`` / ``content`` must be given. A
|
|
59
|
+
``json_payload`` is serialized ONCE here so the signature and the
|
|
60
|
+
POST use the exact same bytes — the body digest covers bytes, not
|
|
61
|
+
JSON semantics. ``headers`` must already contain every X-AAC-*
|
|
62
|
+
header the request will carry (the canonical block is derived by
|
|
63
|
+
rule from them); the two auth headers are merged in last, after
|
|
64
|
+
everything covered is final.
|
|
65
|
+
|
|
66
|
+
``secret`` defaults to the env-configured pairing secret
|
|
67
|
+
(``AAC_INVOKE_AUTH_SECRET_FILE`` — pinned by the repo-root
|
|
68
|
+
conftest for the in-repo suites). Pass it explicitly to exercise
|
|
69
|
+
wrong-secret rejection paths.
|
|
70
|
+
"""
|
|
71
|
+
if (json_payload is None) == (content is None):
|
|
72
|
+
raise ValueError(
|
|
73
|
+
"signed_invoke_post needs exactly one of json_payload= or "
|
|
74
|
+
"content="
|
|
75
|
+
)
|
|
76
|
+
body = (
|
|
77
|
+
content
|
|
78
|
+
if content is not None
|
|
79
|
+
else json.dumps(json_payload).encode("utf-8")
|
|
80
|
+
)
|
|
81
|
+
if secret is None:
|
|
82
|
+
secret = load_invoke_auth_secret_from_env()
|
|
83
|
+
if secret is None:
|
|
84
|
+
raise ValueError(
|
|
85
|
+
"signed_invoke_post found no secret: set "
|
|
86
|
+
"AAC_INVOKE_AUTH_SECRET_FILE (the repo-root conftest "
|
|
87
|
+
"does this for the in-repo suites) or pass secret= "
|
|
88
|
+
"explicitly"
|
|
89
|
+
)
|
|
90
|
+
merged = dict(headers)
|
|
91
|
+
merged.setdefault("Content-Type", "application/json")
|
|
92
|
+
merged.update(
|
|
93
|
+
sign_invoke_request(
|
|
94
|
+
secret=secret,
|
|
95
|
+
method="POST",
|
|
96
|
+
path=path,
|
|
97
|
+
headers=merged,
|
|
98
|
+
body=body,
|
|
99
|
+
)
|
|
100
|
+
)
|
|
101
|
+
return client.post(path, headers=merged, content=body)
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
class InvokeSigningClient:
|
|
105
|
+
"""Transparent signing wrapper around a TestClient/httpx client.
|
|
106
|
+
|
|
107
|
+
``post()`` calls to a protected path are signed via
|
|
108
|
+
:func:`signed_invoke_post`; everything else (GETs, posts to other
|
|
109
|
+
paths, attribute access) passes straight through to the wrapped
|
|
110
|
+
client. Lets an agent test suite keep its natural
|
|
111
|
+
``client.post("/invoke", headers=..., json=...)`` shape while the
|
|
112
|
+
agent runs fully authenticated behind ``InvokeAuthMiddleware``.
|
|
113
|
+
"""
|
|
114
|
+
|
|
115
|
+
def __init__(
|
|
116
|
+
self,
|
|
117
|
+
client: _PostableClient,
|
|
118
|
+
*,
|
|
119
|
+
protected_paths: tuple[str, ...] = ("/invoke",),
|
|
120
|
+
secret: bytes | None = None,
|
|
121
|
+
) -> None:
|
|
122
|
+
self._client = client
|
|
123
|
+
self._protected_paths = frozenset(protected_paths)
|
|
124
|
+
self._secret = secret
|
|
125
|
+
|
|
126
|
+
def post(
|
|
127
|
+
self,
|
|
128
|
+
url: str,
|
|
129
|
+
*,
|
|
130
|
+
headers: dict[str, str] | None = None,
|
|
131
|
+
json: Any | None = None,
|
|
132
|
+
content: bytes | None = None,
|
|
133
|
+
**kwargs: Any,
|
|
134
|
+
) -> Any:
|
|
135
|
+
if url not in self._protected_paths:
|
|
136
|
+
return self._client.post( # type: ignore[call-arg]
|
|
137
|
+
url, headers=headers, json=json, content=content, **kwargs
|
|
138
|
+
)
|
|
139
|
+
if kwargs:
|
|
140
|
+
raise ValueError(
|
|
141
|
+
f"InvokeSigningClient.post to protected {url!r} supports "
|
|
142
|
+
f"only headers=/json=/content=; got {sorted(kwargs)}"
|
|
143
|
+
)
|
|
144
|
+
if json is None and content is None:
|
|
145
|
+
# An intentionally body-less push still gets signed — the
|
|
146
|
+
# digest of b"" is as good as any.
|
|
147
|
+
content = b""
|
|
148
|
+
return signed_invoke_post(
|
|
149
|
+
self._client,
|
|
150
|
+
headers=dict(headers or {}),
|
|
151
|
+
json_payload=json,
|
|
152
|
+
content=content,
|
|
153
|
+
path=url,
|
|
154
|
+
secret=self._secret,
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
def __getattr__(self, name: str) -> Any:
|
|
158
|
+
return getattr(self._client, name)
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
def signing_test_client(app: Any, **testclient_kwargs: Any) -> InvokeSigningClient:
|
|
162
|
+
"""One-call replacement for ``TestClient(app)`` in agent suites.
|
|
163
|
+
|
|
164
|
+
FastAPI's TestClient is imported lazily so this module (and the
|
|
165
|
+
package) stays importable in environments without the ``fastapi``
|
|
166
|
+
extra installed.
|
|
167
|
+
"""
|
|
168
|
+
from fastapi.testclient import TestClient
|
|
169
|
+
|
|
170
|
+
return InvokeSigningClient(TestClient(app, **testclient_kwargs))
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: aac-invoke-auth
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: AAC sidecar-to-agent invoke-push authentication (AAC1-HMAC-SHA256) — signing and verification core, with FastAPI mounting surfaces.
|
|
5
|
+
Author: Agent Authority Cloud Project
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Keywords: aac,agent,authorization,hmac,middleware,fastapi,sidecar
|
|
8
|
+
Classifier: Development Status :: 3 - Alpha
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Topic :: Security
|
|
17
|
+
Classifier: Framework :: FastAPI
|
|
18
|
+
Classifier: Typing :: Typed
|
|
19
|
+
Requires-Python: >=3.10
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
License-File: LICENSE
|
|
22
|
+
Provides-Extra: fastapi
|
|
23
|
+
Requires-Dist: fastapi>=0.115; extra == "fastapi"
|
|
24
|
+
Provides-Extra: test
|
|
25
|
+
Requires-Dist: pytest>=8.0; extra == "test"
|
|
26
|
+
Requires-Dist: fastapi>=0.115; extra == "test"
|
|
27
|
+
Requires-Dist: httpx>=0.28; extra == "test"
|
|
28
|
+
Dynamic: license-file
|
|
29
|
+
|
|
30
|
+
# aac-invoke-auth
|
|
31
|
+
|
|
32
|
+
Authenticate `/invoke` pushes from your paired AAC sidecar.
|
|
33
|
+
|
|
34
|
+
When your agent runs behind an AAC sidecar, the sidecar verifies the
|
|
35
|
+
cross-organizational authority chain and then POSTs the verified context
|
|
36
|
+
to your agent's `/invoke` endpoint. The `X-AAC-*` headers on that push
|
|
37
|
+
are your agent's **entire view** of the verified chain — so your agent
|
|
38
|
+
must be able to tell a genuine sidecar push from a forged one. This
|
|
39
|
+
package is that check: the sidecar HMAC-signs every push with a pairing
|
|
40
|
+
secret shared with exactly one agent, and your agent verifies the
|
|
41
|
+
signature before trusting anything.
|
|
42
|
+
|
|
43
|
+
The verification core is standard-library only (`hmac`, `hashlib`) and
|
|
44
|
+
framework-agnostic. FastAPI mounting surfaces ship behind an extra:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
pip install aac-invoke-auth[fastapi]
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Quick start (FastAPI)
|
|
51
|
+
|
|
52
|
+
Generate the pairing secret once and share the file with your sidecar
|
|
53
|
+
(the sidecar's `sidecar.agent_invoke_auth.secret_file` points at the
|
|
54
|
+
same file; one secret per sidecar–agent pair, never shared across
|
|
55
|
+
pairs):
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
openssl rand -hex 32 > /etc/aac/invoke-auth/invoke-auth.secret
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Point your agent at it and mount the middleware:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
export AAC_INVOKE_AUTH_SECRET_FILE=/etc/aac/invoke-auth/invoke-auth.secret
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
```python
|
|
68
|
+
from fastapi import FastAPI
|
|
69
|
+
from aac_invoke_auth.fastapi import InvokeAuthGuard, InvokeAuthMiddleware
|
|
70
|
+
|
|
71
|
+
app = FastAPI()
|
|
72
|
+
app.add_middleware(
|
|
73
|
+
InvokeAuthMiddleware,
|
|
74
|
+
guard=InvokeAuthGuard.from_env(),
|
|
75
|
+
protected_paths=("/invoke",), # required, exact-match
|
|
76
|
+
)
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
That's the whole integration. Unsigned, tampered, replayed-stale, or
|
|
80
|
+
wrong-secret pushes get a `401` with a generic detail and never reach
|
|
81
|
+
your business logic; your handlers read `request.json()` unchanged.
|
|
82
|
+
|
|
83
|
+
Prefer route-scoped protection? The guard is also a plain FastAPI
|
|
84
|
+
dependency:
|
|
85
|
+
|
|
86
|
+
```python
|
|
87
|
+
from fastapi import Depends
|
|
88
|
+
|
|
89
|
+
guard = InvokeAuthGuard.from_env()
|
|
90
|
+
|
|
91
|
+
@app.post("/invoke", dependencies=[Depends(guard)])
|
|
92
|
+
async def invoke(request: Request): ...
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Both surfaces call the same verifier — pick whichever fits your app.
|
|
96
|
+
|
|
97
|
+
## Fail-fast startup, by design
|
|
98
|
+
|
|
99
|
+
`InvokeAuthGuard.from_env()` **refuses to start** when
|
|
100
|
+
`AAC_INVOKE_AUTH_SECRET_FILE` is unset. A missing secret is a security
|
|
101
|
+
downgrade; it should fail your deployment loudly at boot, not degrade
|
|
102
|
+
into a log line nobody reads.
|
|
103
|
+
|
|
104
|
+
The single escape hatch — for extraordinary cases only, such as tenant
|
|
105
|
+
test/pilot environments or debugging a suspected signing mismatch — is
|
|
106
|
+
setting
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
export AAC_INVOKE_AUTH_ALLOW_UNAUTHENTICATED=true
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
explicitly (only the exact value `true`; a typo still fails the boot).
|
|
113
|
+
An opted-out agent accepts every push unverified and logs a prominent
|
|
114
|
+
warning at startup so the posture is visible in your logs. Never run
|
|
115
|
+
this in production: the sidecar side has a symmetric `dev_mode`
|
|
116
|
+
interlock, and both exist to make "unauthenticated" impossible to reach
|
|
117
|
+
by accident.
|
|
118
|
+
|
|
119
|
+
## Testing your agent
|
|
120
|
+
|
|
121
|
+
`aac_invoke_auth.testing` ships with the package:
|
|
122
|
+
|
|
123
|
+
```python
|
|
124
|
+
from aac_invoke_auth.testing import signing_test_client
|
|
125
|
+
|
|
126
|
+
client = signing_test_client(app) # wraps FastAPI's TestClient
|
|
127
|
+
response = client.post("/invoke", headers=aac_headers, json=payload)
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
`post()` calls to protected paths are signed exactly the way the paired
|
|
131
|
+
sidecar signs them (secret read from `AAC_INVOKE_AUTH_SECRET_FILE`);
|
|
132
|
+
everything else passes through. So your test suite exercises the real
|
|
133
|
+
production verification path instead of opting out of it.
|
|
134
|
+
|
|
135
|
+
## Wire format
|
|
136
|
+
|
|
137
|
+
`AAC1-HMAC-SHA256` over method, path, timestamp, a SHA-256 body digest,
|
|
138
|
+
and every `X-AAC-*` header (derived by rule, so header
|
|
139
|
+
insertion/removal after signing fails verification). Freshness window
|
|
140
|
+
±30s. The normative canonicalization text lives in the AAC Engineering
|
|
141
|
+
Specification §III.2.4a; frozen known-answer vectors live in this
|
|
142
|
+
package's test suite — a change that breaks a vector is a wire-format
|
|
143
|
+
break, not a refactor.
|
|
144
|
+
|
|
145
|
+
Ports of this middleware for other stacks (Express, Spring, Go
|
|
146
|
+
net/http) follow the same model; the core stays standard-library-only
|
|
147
|
+
in every language precisely to keep those ports mechanical.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
aac_invoke_auth/__init__.py,sha256=OWoh1mV278Vf4oiOuG2_qqmOLfYyAQfPeLRQo_sxNpY,14326
|
|
2
|
+
aac_invoke_auth/fastapi.py,sha256=wVT6VVeEeZQ1FcRpOZxj4JbRElgdxExRZDSvwy7UlnI,14979
|
|
3
|
+
aac_invoke_auth/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
+
aac_invoke_auth/testing.py,sha256=owAOpGd_IM1em6FOX5M_GMyCwSGdSFFgKdQ4-F3PFWU,5816
|
|
5
|
+
aac_invoke_auth-0.1.0.dist-info/licenses/LICENSE,sha256=DVQuDIgE45qn836wDaWnYhSdxoLXgpRRKH4RuTjpRZQ,10174
|
|
6
|
+
aac_invoke_auth-0.1.0.dist-info/METADATA,sha256=g5ic6fO8704qg6wGGHo4MpzaCsX8cvH9CqacIlxD9uo,5256
|
|
7
|
+
aac_invoke_auth-0.1.0.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
|
|
8
|
+
aac_invoke_auth-0.1.0.dist-info/top_level.txt,sha256=xuiAqCukQDD7NOO1LoPAoHYv2cH2nCTk3mFEg7Ve3I4,16
|
|
9
|
+
aac_invoke_auth-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
aac_invoke_auth
|