patchwork-rb 0.1.7 → 0.1.8
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.
- checksums.yaml +4 -4
- data/README.md +4 -3
- data/lib/patchwork/mint.rb +10 -2
- data/lib/patchwork/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a83f39124088d921584da26ad346e4d61161b843f0495771ab0342c14cb88879
|
|
4
|
+
data.tar.gz: 3dde8e91a81d42d90c449d5789720cce885712ce7452dcd025d6e082e3e9d2a4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e9071f60b2b687cd47ae7526a8ef92b603ccc7df804d1051275efe7a74ea2f2cc4eae601560be959346ef9114977794248b4bba4024a49f52c0e8e8358868e85
|
|
7
|
+
data.tar.gz: 687340d10a3cd2e15857bdfa8f712e72e9d9d9ce94bf4ff32966121bebca0a441bcb861791846a6f65a38a7ad095f51eb0f010551011f5318f3ad5ca7215e11d
|
data/README.md
CHANGED
|
@@ -126,7 +126,8 @@ class PatchworkController < ApplicationController
|
|
|
126
126
|
render json: Patchwork::Mint.relay(
|
|
127
127
|
body: request.raw_post,
|
|
128
128
|
signature: request.headers["Patchwork-Signature"],
|
|
129
|
-
path: request.path
|
|
129
|
+
path: request.path,
|
|
130
|
+
query: request.query_string
|
|
130
131
|
), status: :created
|
|
131
132
|
rescue Patchwork::InvalidSignature
|
|
132
133
|
head :unauthorized
|
|
@@ -140,7 +141,7 @@ Build the subject from server state, never from request params. On the direct br
|
|
|
140
141
|
|
|
141
142
|
Set `connection_id` in your configuration when the agent has unpinned customer tools, and every minted token carries it — the direct branch, the relay branch, and the gateway. `issue` also takes `connection_id:` for a one-off. It is a connection UUID, not a name.
|
|
142
143
|
|
|
143
|
-
`Mint.relay` mints for exactly the subject Patchwork sent, never a default, and verifies the signature before it reads the subject at all. `jwks` publishes the public half of your signing key, so Patchwork can verify what you minted. Set its URL on your workspace.
|
|
144
|
+
`Mint.relay` mints for exactly the subject Patchwork sent, never a default, and verifies the signature before it reads the subject at all. Pass `query:` — Patchwork signs the query it sends, so a `mint_url` that carries one needs it here or the `v2` value is checked against the bare path. `labels:` works here too, if you want to require `v2`. `jwks` publishes the public half of your signing key, so Patchwork can verify what you minted. Set its URL on your workspace.
|
|
144
145
|
|
|
145
146
|
If you mount the gateway in section 4, `mint_path: "/patchwork/mint"` makes it answer the relay call before your controller sees it, and you can drop `relay_mint`. Your frontend's unsigned request still reaches `mint`.
|
|
146
147
|
|
|
@@ -248,7 +249,7 @@ use Patchwork::Gateway,
|
|
|
248
249
|
labels: [ Patchwork::Signature::V2 ]
|
|
249
250
|
```
|
|
250
251
|
|
|
251
|
-
Requiring `v2` refuses any signature that does not cover the query. Patchwork sends `v2` on every tool
|
|
252
|
+
Requiring `v2` refuses any signature that does not cover the query. Patchwork sends `v2` on every signed call — tool calls, a patch dry run, the relay mint, the connection probe and webhook deliveries — so this is safe to turn on today. It will fail against a platform that has not started sending `v2`, which is why it is not the default.
|
|
252
253
|
|
|
253
254
|
Or give any tool whose arguments matter — ids, amounts, anything that writes — a `POST` binding, where the arguments travel in the signed body.
|
|
254
255
|
|
data/lib/patchwork/mint.rb
CHANGED
|
@@ -16,11 +16,19 @@ module Patchwork
|
|
|
16
16
|
# Verifies the presenter signature, then mints for exactly the subject in
|
|
17
17
|
# the body — never a default, never a widened one. Raises InvalidSignature,
|
|
18
18
|
# StaleSignature or BadRequest.
|
|
19
|
+
# `query:` is the raw query string the request arrived with. Patchwork signs
|
|
20
|
+
# the query it sends, so a mint_url that carries one needs it here or the
|
|
21
|
+
# v2 value is checked against the bare path. Pass it whenever you have it;
|
|
22
|
+
# the gateway does this for you.
|
|
19
23
|
def self.relay(body:, signature:, path:, secrets: Patchwork.config.request_secrets,
|
|
20
|
-
connection_id: Patchwork.config.connection_id
|
|
24
|
+
connection_id: Patchwork.config.connection_id,
|
|
25
|
+
query: nil, labels: Signature::LABELS)
|
|
21
26
|
raise BadRequest, "mint body too large" if body.to_s.bytesize > MAX_BODY_BYTES
|
|
22
27
|
|
|
23
|
-
Signature.verify!(
|
|
28
|
+
Signature.verify!(
|
|
29
|
+
secrets: secrets, header: signature, method: "POST", path: path,
|
|
30
|
+
query: query, body: body, labels: labels
|
|
31
|
+
)
|
|
24
32
|
token = SessionToken.issue(subject: relay_subject(body), connection_id: connection_id)
|
|
25
33
|
{ token: token, expires_in: Patchwork.config.token_ttl }
|
|
26
34
|
end
|
data/lib/patchwork/version.rb
CHANGED