regent-httpsig 0.7.2__tar.gz → 0.8.0__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.
Files changed (45) hide show
  1. regent_httpsig-0.8.0/.github/workflows/release.yml +68 -0
  2. {regent_httpsig-0.7.2 → regent_httpsig-0.8.0}/CHANGELOG.md +210 -0
  3. regent_httpsig-0.8.0/PKG-INFO +549 -0
  4. regent_httpsig-0.8.0/README.md +517 -0
  5. {regent_httpsig-0.7.2 → regent_httpsig-0.8.0}/SECURITY.md +7 -0
  6. {regent_httpsig-0.7.2 → regent_httpsig-0.8.0}/examples/fastapi_verify.py +10 -3
  7. {regent_httpsig-0.7.2 → regent_httpsig-0.8.0}/pyproject.toml +4 -2
  8. {regent_httpsig-0.7.2 → regent_httpsig-0.8.0}/src/regent_httpsig/__init__.py +5 -1
  9. regent_httpsig-0.8.0/src/regent_httpsig/config.py +125 -0
  10. {regent_httpsig-0.7.2 → regent_httpsig-0.8.0}/src/regent_httpsig/fastapi.py +81 -19
  11. regent_httpsig-0.8.0/src/regent_httpsig/jwk.py +130 -0
  12. {regent_httpsig-0.7.2 → regent_httpsig-0.8.0}/src/regent_httpsig/netguard.py +10 -1
  13. regent_httpsig-0.8.0/src/regent_httpsig/replay.py +141 -0
  14. {regent_httpsig-0.7.2 → regent_httpsig-0.8.0}/src/regent_httpsig/sfv.py +74 -8
  15. {regent_httpsig-0.7.2 → regent_httpsig-0.8.0}/src/regent_httpsig/verify.py +495 -115
  16. {regent_httpsig-0.7.2 → regent_httpsig-0.8.0}/tests/test_budget.py +1 -1
  17. regent_httpsig-0.8.0/tests/test_fastapi_origins.py +149 -0
  18. regent_httpsig-0.8.0/tests/test_headers.py +123 -0
  19. regent_httpsig-0.8.0/tests/test_jwk.py +308 -0
  20. {regent_httpsig-0.7.2 → regent_httpsig-0.8.0}/tests/test_netguard.py +21 -0
  21. regent_httpsig-0.8.0/tests/test_replay.py +544 -0
  22. {regent_httpsig-0.7.2 → regent_httpsig-0.8.0}/tests/test_verifier.py +84 -6
  23. regent_httpsig-0.8.0/tests/test_web_bot_auth.py +1020 -0
  24. regent_httpsig-0.7.2/.github/workflows/release.yml +0 -33
  25. regent_httpsig-0.7.2/PKG-INFO +0 -309
  26. regent_httpsig-0.7.2/README.md +0 -279
  27. regent_httpsig-0.7.2/src/regent_httpsig/config.py +0 -62
  28. regent_httpsig-0.7.2/src/regent_httpsig/jwk.py +0 -46
  29. {regent_httpsig-0.7.2 → regent_httpsig-0.8.0}/.github/workflows/ci.yml +0 -0
  30. {regent_httpsig-0.7.2 → regent_httpsig-0.8.0}/.gitignore +0 -0
  31. {regent_httpsig-0.7.2 → regent_httpsig-0.8.0}/CONTRIBUTING.md +0 -0
  32. {regent_httpsig-0.7.2 → regent_httpsig-0.8.0}/GOVERNANCE.md +0 -0
  33. {regent_httpsig-0.7.2 → regent_httpsig-0.8.0}/LICENSE +0 -0
  34. {regent_httpsig-0.7.2 → regent_httpsig-0.8.0}/MAINTAINERS.md +0 -0
  35. {regent_httpsig-0.7.2 → regent_httpsig-0.8.0}/examples/httpx_signer.py +0 -0
  36. {regent_httpsig-0.7.2 → regent_httpsig-0.8.0}/src/regent_httpsig/budget.py +0 -0
  37. {regent_httpsig-0.7.2 → regent_httpsig-0.8.0}/src/regent_httpsig/cli.py +0 -0
  38. {regent_httpsig-0.7.2 → regent_httpsig-0.8.0}/src/regent_httpsig/py.typed +0 -0
  39. {regent_httpsig-0.7.2 → regent_httpsig-0.8.0}/src/regent_httpsig/sign.py +0 -0
  40. {regent_httpsig-0.7.2 → regent_httpsig-0.8.0}/src/regent_httpsig/usage.py +0 -0
  41. {regent_httpsig-0.7.2 → regent_httpsig-0.8.0}/tests/test_signer.py +0 -0
  42. {regent_httpsig-0.7.2 → regent_httpsig-0.8.0}/tests/test_usage.py +0 -0
  43. {regent_httpsig-0.7.2 → regent_httpsig-0.8.0}/tests/test_vectors.py +0 -0
  44. {regent_httpsig-0.7.2 → regent_httpsig-0.8.0}/vectors/aauth-budgets-vectors.json +0 -0
  45. {regent_httpsig-0.7.2 → regent_httpsig-0.8.0}/vectors/generate.py +0 -0
@@ -0,0 +1,68 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ tags: ["v*"]
6
+
7
+ permissions:
8
+ contents: read # default for every job; the one that writes says so itself
9
+
10
+ jobs:
11
+ build:
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - uses: actions/checkout@v4
15
+ - uses: actions/setup-python@v5
16
+ with:
17
+ python-version: "3.12"
18
+ - run: python -m pip install build
19
+ - run: python -m build
20
+ - uses: actions/upload-artifact@v4
21
+ with:
22
+ name: dist
23
+ path: dist/
24
+
25
+ publish:
26
+ needs: build
27
+ runs-on: ubuntu-latest
28
+ environment: pypi
29
+ permissions:
30
+ id-token: write # OIDC trusted publishing — no tokens anywhere
31
+ steps:
32
+ - uses: actions/download-artifact@v4
33
+ with:
34
+ name: dist
35
+ path: dist/
36
+ - uses: pypa/gh-action-pypi-publish@release/v1
37
+
38
+ github-release:
39
+ # After PyPI has the files: a GitHub Release for the tag, with that
40
+ # version's CHANGELOG.md section as notes and the same dist files attached.
41
+ needs: publish
42
+ runs-on: ubuntu-latest
43
+ permissions:
44
+ contents: write # create the release and upload its assets; nothing else
45
+ steps:
46
+ - uses: actions/checkout@v4
47
+ - uses: actions/download-artifact@v4
48
+ with:
49
+ name: dist
50
+ path: dist/
51
+ - name: Release notes from CHANGELOG.md
52
+ env:
53
+ TAG: ${{ github.ref_name }}
54
+ run: |
55
+ version="${TAG#v}"
56
+ awk -v v="$version" '
57
+ /^## / { if (found) exit; found = ($2 == v); next }
58
+ found { print }
59
+ ' CHANGELOG.md > notes.md
60
+ if ! grep -q '[^[:space:]]' notes.md; then
61
+ echo "CHANGELOG.md has no section for $version" >&2
62
+ exit 1
63
+ fi
64
+ - name: Create the GitHub Release
65
+ env:
66
+ GH_TOKEN: ${{ github.token }}
67
+ TAG: ${{ github.ref_name }}
68
+ run: gh release create "$TAG" dist/* --verify-tag --title "$TAG" --notes-file notes.md
@@ -1,5 +1,215 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.8.0
4
+
5
+ **Relying-party security release.** What a verified signature names is now
6
+ the same thing in every scheme (the thumbprint of the key that verified it),
7
+ Web Bot Auth follows draft-ietf-webbotauth-httpsig-protocol-01 (29 October
8
+ 2026), keys are read only from canonical base64url, and an opt-in replay
9
+ guard is available. Upgrade from any 0.7.x; see the supported versions in
10
+ `SECURITY.md`.
11
+
12
+ ### Breaking changes
13
+
14
+ - **Server signatures on the generic path.** `verify()` / `verify_detailed()`
15
+ accept the `jwks_uri` server scheme only from an `id` listed in
16
+ `trusted_ps`; anything else is `invalid_key`.
17
+ `HttpsigConfig(allow_unpinned_servers=True)` restores the old behaviour.
18
+ `verify_server()`, the entry point for usage and revocation endpoints, is
19
+ unchanged in that respect.
20
+ - **`keyid` of a server signature** is the RFC 7638 thumbprint of the JWK
21
+ that verified it, no longer the `kid` the server chose (still in
22
+ `claims["kid"]`). Code that compared a server's `keyid` with its `kid`
23
+ must use `claims["kid"]`.
24
+ - **Web Bot Auth covered components** (-01 §5.2): a signature must cover
25
+ `@authority` (or `@target-uri`) and the `Signature-Agent` member it is
26
+ attributed to; otherwise `invalid_input` with `required_input`.
27
+ 0.7 accepted any coverage, including none.
28
+ - **Web Bot Auth `expires` is required** (-01 §5.2), and has no grace: a
29
+ signature checked at or after `expires` is refused (0.7 allowed 5 s
30
+ past it). `wba_require_expires=False` accepts signatures without
31
+ `expires` (their age is still bounded by `max_age_hours`).
32
+ - **AAuth `expires`**: a request signature checked at its `expires` second
33
+ is refused (0.7.x refused only after it).
34
+ - **Web Bot Auth attribution**: a signature is attributed only to the
35
+ `Signature-Agent` member it covers (0.7 took the first member); a member
36
+ with parameters, a non-https URL or a URL with userinfo is not used.
37
+ `sig.agent` is normalized as -01 §5.5 asks (RFC 3986 §6.2.2/§6.2.3:
38
+ lowercase scheme and host, default port dropped, percent-encoded
39
+ unreserved characters decoded, other escapes uppercased, dot segments
40
+ removed; a bare origin loses its trailing `/`), and so are
41
+ `trusted_agents` entries when compared. The normalized URL is the one
42
+ fetched.
43
+ - **Web Bot Auth key location** (-01 §5.5): a `Signature-Agent` URL with a
44
+ path is fetched directly as the JWK Set and is the identifier (without
45
+ its query); a bare origin, or the well-known URL itself, still resolves
46
+ to `{origin}/.well-known/http-message-signatures-directory` and is
47
+ identified by the origin, as before.
48
+ - **Only the first `web-bot-auth` signature** of a request is verified, on
49
+ its own (0.7 verified every tagged signature against the first member's
50
+ directory and failed if any did not verify).
51
+ - **A body the verifier cannot see is no longer ignored.** When the body is
52
+ passed, it decides (an empty one is no body, whatever the framing says).
53
+ When it is not, the framing decides (`Content-Length` above zero,
54
+ `Transfer-Encoding`, `Content-Digest`). When
55
+ such a request must cover `content-digest` (always on the AAuth path; on
56
+ the Web Bot Auth path when configured) and the body was not passed to
57
+ `verify()`, it is refused (`invalid_signature`): 0.7 accepted it with the
58
+ digest unchecked, or required nothing at all when no `Content-Digest` was
59
+ sent.
60
+ - **Web Bot Auth refusals carry specific codes** in `verify_detailed()`
61
+ (`invalid_input`, `clock_skew`, `invalid_signature` with a detail)
62
+ instead of one generic `invalid_signature`.
63
+ - **Directories and metadata must answer `200`** exactly; 0.7 accepted any
64
+ 2xx.
65
+ - **A Web Bot Auth directory is served stale during an outage.** When its
66
+ refetch fails, the last good copy is still used for up to
67
+ `wba_max_stale_seconds` (600) after `cache_ttl`, so a key the operator
68
+ removed can verify that much longer while the directory is unreachable;
69
+ 0.7 failed on the first failed refetch. `wba_max_stale_seconds=0`
70
+ restores that. AAuth issuer and server JWKS are never served stale.
71
+ - **The SSRF guard resolves the host httpx connects to** (IDNA 2008). It
72
+ resolved a Unicode name with Python's IDNA 2003 codec (ß -> ss), which can
73
+ be another host than the one httpx then connected to.
74
+ - **A header under two spellings is refused** when the verification depends
75
+ on it (the signature fields, `Content-Digest`, `Content-Type`,
76
+ `Content-Length`, `Transfer-Encoding`, `Host`, any covered field). The
77
+ mapping is normalised once, so the verifier's checks and the RFC 9421
78
+ library read the same value. 0.7 read the first spelling in its own checks
79
+ and the upstream library the last: with a case-preserving mapping an
80
+ expired signature passed, required components were bypassed, and a
81
+ signature was attributed to another origin. The AAuth path had the same
82
+ hole since 0.7.0.
83
+ - **Key members must be canonical base64url** (URL-safe alphabet, no
84
+ padding, zero unused bits, exact size; RSA in minimal octets): Web Bot
85
+ Auth directory keys spelled otherwise are skipped, AAuth possession,
86
+ issuer and server keys are `invalid_key`. `load_ed25519_jwk()` raises
87
+ on them. `jwk_thumbprint()` hashes the canonical re-encoding (for RSA
88
+ `n`/`e`, the integer in its minimum octets: a leading `0x00` does not
89
+ make a second keyid), so a non-canonical JWK now has the thumbprint of the
90
+ key it encodes, and a member with characters outside the base64 alphabets
91
+ raises `ValueError`.
92
+
93
+ ### Added
94
+
95
+ - `HttpsigConfig.wba_required_components` (default `("@authority",
96
+ "signature-agent")`; `@target-uri` stands in for `@authority`, `@path`,
97
+ `@query`, `@scheme`; `content-digest` applies to requests with a body and
98
+ is checked against the body), `wba_require_expires` (default `True`),
99
+ `wba_max_validity_seconds` (default `None`), `allow_unpinned_servers`
100
+ (default `False`); `config.WBA_REQUIRED_COMPONENTS`. The README says
101
+ which stricter values a relying party that moves money should set.
102
+ - Replay guard: `ReplayGuard` (one async call,
103
+ `first_use(key, *, until, partition) -> bool`), `InMemoryReplayGuard`
104
+ (bounded, per process, one partition holds at most `max_share` of it,
105
+ fails closed when full, never evicts a live entry), `ReplayGuardFull`
106
+ (`.partition`), `HttpsigVerifier(replay_guard=…)`. Applied on the Web Bot
107
+ Auth path, the AAuth jwt path and the server scheme; keyed on the scheme,
108
+ the keyid and the signature base (not the `Signature` bytes: an ECDSA
109
+ signature has a twin that verifies too); partitioned by the host that
110
+ vouches for the key (directory, issuer or server host, as the ASCII name
111
+ httpx connects to; lowercase, no trailing dot, port ignored). With a guard, a
112
+ signature is admitted only `HttpsigConfig.replay_window_seconds` (300)
113
+ after `created` and remembered until `min(expires, created + 301)`. A
114
+ replay or a full guard is `invalid_signature`. Without a guard nothing
115
+ changes.
116
+ - A Web Bot Auth `keyid` selects a directory key by thumbprint, then by
117
+ `kid` (Google-Agent's directory labels its keys with short kids); the
118
+ reported `keyid` is always the thumbprint.
119
+ - A failed refetch of a Web Bot Auth directory keeps serving the last good
120
+ copy (-01 §6.10: a failure is not evidence and must not evict cached keys)
121
+ for at most `HttpsigConfig.wba_max_stale_seconds` (default 600) after it
122
+ went stale; then a failed refetch is a failure. Only a successful fetch
123
+ replaces the copy. 0.7 dropped the keys on the first failed refetch after
124
+ `cache_ttl`, which AAuth issuer and server JWKS still do — also when a Web
125
+ Bot Auth request names the same URL: a stale copy is handed only to the
126
+ Web Bot Auth path and never stored as a fresh entry.
127
+ - A verified Web Bot Auth signature carries `claims["directory"]` (the exact
128
+ URL the key was fetched from, query included; `agent` is the identifier
129
+ without it) and `claims["jwk"]` (the key, RFC 7638 members).
130
+ - `jwk.b64url_decode_strict()`, `jwk.check_jwk_members()`,
131
+ `sfv.parse_covered_components()`, `sfv.signature_agent_member()`.
132
+ - The FastAPI layer hands the body to the Web Bot Auth path when a
133
+ `Content-Digest` is present or the configuration requires one.
134
+ - `HttpsigConfig.public_origins` (FastAPI layer): this service's public
135
+ origin(s). When set, the URL a signature is verified against is built
136
+ from the configured origin matching `Host`, and a signed request whose
137
+ `Host` is none of them is refused before verification. A host configured
138
+ under both `http://` and `https://`: `X-Forwarded-Proto` decides, else
139
+ `https://` (never the connection's scheme), so a plain-http client
140
+ reaching the service without a proxy, whose signature covers
141
+ `@target-uri` or `@scheme`, is refused. Unset, the URL is
142
+ rebuilt from the client's `Host` and `X-Forwarded-Proto` as in 0.7, so a
143
+ signature made for another site verifies when replayed with that site's
144
+ `Host` unless the proxy in front passes only this service's names; the
145
+ README now says so, and tells framework-free callers to pass the URL of
146
+ their own public origin.
147
+ - `regent_httpsig.fastapi.verify_server_request(request, *,
148
+ allowed_dwk=SERVER_DWKS)`: the non-raising server-signature check behind
149
+ `require_server_signature`, using the same URL (`public_origins` when
150
+ set); `allowed_dwk` means what it means in `verify_server()`. Pass it (or a
151
+ `functools.partial` of it) as `authenticate_ps=` to the usage and
152
+ revocation endpoints; the README example no longer builds the URL from
153
+ `request.url`.
154
+
155
+ ### Upgrading from 0.7.x
156
+
157
+ Check each of these; the first two can refuse requests 0.7 accepted.
158
+
159
+ - **Pass the request body.** A request that has a body (passed, or by its
160
+ framing when not passed) and must cover `content-digest` is refused when
161
+ the body is not passed to `verify()`. The FastAPI layer passes it.
162
+ - **Verify against your own origin.** Framework-free, pass `verify()` the
163
+ URL of your own public origin, never one built from the client's `Host`.
164
+ With FastAPI, set `HttpsigConfig.public_origins`; unset, the client's
165
+ `Host` decides `@authority` as in 0.7.
166
+ - **Server signatures.** `verify()` accepts the `jwks_uri` scheme only from
167
+ `trusted_ps` (`allow_unpinned_servers=True` to reopen), and a server's
168
+ `keyid` is now the thumbprint (`claims["kid"]` keeps the label). For usage
169
+ and revocation endpoints use `authenticate_ps=verify_server_request`
170
+ (`allowed_dwk` to restrict the caller's document).
171
+ - **Web Bot Auth strictness.** `@authority` (or `@target-uri`), the
172
+ `Signature-Agent` member and `expires` are required, `expires` has no
173
+ grace, keys must be canonical. Loosen with `wba_required_components` /
174
+ `wba_require_expires`; tighten for money as the README shows.
175
+ - **Replay guard (new).** The protocol is final for 0.8:
176
+ `async first_use(key, *, until, partition) -> bool`, raising
177
+ `ReplayGuardFull` (or anything else) to refuse. Size
178
+ `InMemoryReplayGuard(max_entries, max_share)` and
179
+ `replay_window_seconds` for your traffic.
180
+ - **Stale limits.** Web Bot Auth directories: `wba_max_stale_seconds`
181
+ (600; `0` for the 0.7 behaviour). AAuth JWKS: never stale.
182
+
183
+ ### Fixed
184
+
185
+ - Strict mypy passes again: CI on `main` had failed since 0.7.2 on unused
186
+ `type: ignore` comments.
187
+
188
+ `max_age_hours` (25) still bounds the age of a Web Bot Auth `created` even
189
+ when `expires` is later — stricter than -01, which sets no upper bound, so
190
+ that a far `expires` does not make a long-lived credential (-01 §6.9). Raise
191
+ it to accept longer-lived signatures.
192
+
193
+ `http-message-signatures` stays below 2.1.
194
+
195
+ ## 0.7.3
196
+
197
+ 25 October 2026.
198
+
199
+ - The `http-message-signatures` bound is `<2.1`, as 0.7.2 meant it to be
200
+ (0.7.2 shipped with `<3`).
201
+
202
+ ## 0.7.2
203
+
204
+ 25 October 2026. **Broken — do not use; install 0.7.3 or later.**
205
+
206
+ - `http-message-signatures` 2.1.0 (19 October 2026) replaced its vendored
207
+ `http_sfv` module with the `http-sf` package and reworked its verifier
208
+ internals. 0.7.1, 0.7.0 and older resolve 2.2 on a fresh install and fail
209
+ at import. 0.7.2 reads the structured-field module from `http_sf.compat`
210
+ when the vendored one is gone, but its bound was `<3`: a fresh install
211
+ resolves 2.2, imports, and then fails AAuth verification at runtime.
212
+
3
213
  ## 0.7.1
4
214
 
5
215
  - Ship the `py.typed` marker: the package has been mypy-strict since 0.1, and