patchwork-rb 0.1.3 → 0.1.4
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 +3 -2
- data/lib/patchwork/configuration.rb +2 -2
- data/lib/patchwork/gateway.rb +2 -1
- data/lib/patchwork/mint.rb +4 -2
- data/lib/patchwork/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c5b4e037d427bdd50e672f5f08ff93f8f4e129c42c998224162f7a6296988d2c
|
|
4
|
+
data.tar.gz: 59c03fbcbbfff9f6b6c27a006f3b37da9f8d995c3bb1f29d1168af2c619d6f17
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ee481c8625a8556c87f7924a4766e77588c0dbcd9a3529cb1041b74cafcc4610cdb1063f00ff607daac78eb1ef93861086926be81b2a897d029b47bfbc472a08
|
|
7
|
+
data.tar.gz: b0392464c771cfd3323ac2384cce4982f9bf75f62fbe79f7c03f578480b9ed1be0817a6f5e4ad89a7dd0c23161e5306d693fa878c5098121e366d9d56191ecb3
|
data/README.md
CHANGED
|
@@ -32,6 +32,7 @@ end
|
|
|
32
32
|
| `audience` | minting, tool calls | No default. Tokens carry `["patchwork", audience]`, and tool calls are verified against it. |
|
|
33
33
|
| `request_secret` | tool calls, health check | Set `previous_request_secret` during a rotation. |
|
|
34
34
|
| `signing_kid` | optional | Defaults to the key's RFC 7638 thumbprint, so a new key gets a new `kid` automatically. |
|
|
35
|
+
| `connection_id` | optional | Set it when the agent has unpinned customer tools. A connection UUID, not a name. Minted tokens carry it as `conn`, including the ones the relay mint and the gateway issue. |
|
|
35
36
|
| `token_ttl` | optional | Seconds. Defaults to 120. The browser remints as needed. |
|
|
36
37
|
| `max_token_lifetime` | optional | Seconds. Defaults to 900. Verification refuses a token whose own `exp - iat` is longer, so a good signature over an absurd expiry is still rejected. `nil` turns the check off. |
|
|
37
38
|
|
|
@@ -137,9 +138,9 @@ end
|
|
|
137
138
|
|
|
138
139
|
Build the subject from server state, never from request params. On the direct branch that is the whole of your authorisation.
|
|
139
140
|
|
|
140
|
-
`
|
|
141
|
+
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.
|
|
141
142
|
|
|
142
|
-
`jwks` publishes the public half of your signing key, so Patchwork can verify what you minted. Set its URL on your workspace.
|
|
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.
|
|
143
144
|
|
|
144
145
|
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`.
|
|
145
146
|
|
|
@@ -10,7 +10,7 @@ module Patchwork
|
|
|
10
10
|
# and the one it replaced while a rotation is in flight.
|
|
11
11
|
attr_accessor :signing_key, :signing_kid, :issuer, :audience,
|
|
12
12
|
:request_secret, :previous_request_secret, :token_ttl,
|
|
13
|
-
:max_token_lifetime
|
|
13
|
+
:max_token_lifetime, :connection_id
|
|
14
14
|
|
|
15
15
|
DEFAULT_TTL = 120
|
|
16
16
|
DEFAULT_MAX_TOKEN_LIFETIME = 900
|
|
@@ -45,7 +45,7 @@ module Patchwork
|
|
|
45
45
|
# Default #inspect prints every ivar, so a config that reaches a log line,
|
|
46
46
|
# an error tracker or a console would carry the private key with it.
|
|
47
47
|
def inspect
|
|
48
|
-
fields = %i[issuer audience signing_kid token_ttl max_token_lifetime].map { |name| "#{name}=#{public_send(name).inspect}" }
|
|
48
|
+
fields = %i[issuer audience signing_kid connection_id token_ttl max_token_lifetime].map { |name| "#{name}=#{public_send(name).inspect}" }
|
|
49
49
|
fields += SECRETS.map { |name| "#{name}=#{public_send(name).to_s.empty? ? 'nil' : '[REDACTED]'}" }
|
|
50
50
|
"#<Patchwork::Configuration #{fields.join(', ')}>"
|
|
51
51
|
end
|
data/lib/patchwork/gateway.rb
CHANGED
|
@@ -97,7 +97,8 @@ module Patchwork
|
|
|
97
97
|
def relay_mint(request, signature)
|
|
98
98
|
body = verify_signature!(request, signature, limit: MAX_CONTROL_BODY_BYTES)
|
|
99
99
|
subject = Mint.relay_subject(body)
|
|
100
|
-
|
|
100
|
+
token = SessionToken.issue(subject: subject, connection_id: Patchwork.config.connection_id)
|
|
101
|
+
json(201, { token: token, expires_in: Patchwork.config.token_ttl })
|
|
101
102
|
rescue Mint::BadRequest => e
|
|
102
103
|
json(400, { error: e.message })
|
|
103
104
|
end
|
data/lib/patchwork/mint.rb
CHANGED
|
@@ -16,11 +16,13 @@ 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
|
-
def self.relay(body:, signature:, path:, secrets: Patchwork.config.request_secrets
|
|
19
|
+
def self.relay(body:, signature:, path:, secrets: Patchwork.config.request_secrets,
|
|
20
|
+
connection_id: Patchwork.config.connection_id)
|
|
20
21
|
raise BadRequest, "mint body too large" if body.to_s.bytesize > MAX_BODY_BYTES
|
|
21
22
|
|
|
22
23
|
Signature.verify!(secrets: secrets, header: signature, method: "POST", path: path, body: body)
|
|
23
|
-
|
|
24
|
+
token = SessionToken.issue(subject: relay_subject(body), connection_id: connection_id)
|
|
25
|
+
{ token: token, expires_in: Patchwork.config.token_ttl }
|
|
24
26
|
end
|
|
25
27
|
|
|
26
28
|
def self.relay_subject(body)
|
data/lib/patchwork/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: patchwork-rb
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Chromablue Labs
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-10-
|
|
11
|
+
date: 2026-10-05 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: jwt
|