patchwork-rb 0.1.5 → 0.1.6
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 +2 -0
- data/lib/patchwork/gateway.rb +13 -2
- data/lib/patchwork/rails.rb +1 -0
- data/lib/patchwork/version.rb +1 -1
- data/lib/patchwork.rb +8 -0
- 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: 564b479edcfcbad47a6b170dc219eecc6a5cd633c066f10a070631dd12583860
|
|
4
|
+
data.tar.gz: 0f0768a2e84d273f34eaebb0a6bef98f280dc6ff193f8ee72ded3ab6b3b9595a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b4b7217e76620606f0b16b56d1e1828ebc0b36b86f2c99100ae0324adef914d772ca425017dc76a7e1c88f005c46586fd55be8ba5cb1abea895fb0dabf77e9d6
|
|
7
|
+
data.tar.gz: 71b097330f26014ec0447a8fb90afa21d67400b6314bbb3783b6399a7ce1669d91773ce9054aba74ba76370b95b833e027a73ab5fd1c38f5c1ca31c4e83658d3
|
data/README.md
CHANGED
|
@@ -213,6 +213,8 @@ use Patchwork::Gateway, resolve: ->(subject, claims) {
|
|
|
213
213
|
|
|
214
214
|
`resolve` can take `(subject)` or `(subject, claims)`. Any object that responds to `call` works.
|
|
215
215
|
|
|
216
|
+
A verified call answers with `Patchwork-Sdk: patchwork-rb/<version>`, so Patchwork can tell which version you run and retire an old signature label on evidence rather than a guess. A request that falls through to your own auth does not carry it.
|
|
217
|
+
|
|
216
218
|
After a successful call, the request env carries:
|
|
217
219
|
|
|
218
220
|
| Key | Value |
|
data/lib/patchwork/gateway.rb
CHANGED
|
@@ -63,7 +63,7 @@ module Patchwork
|
|
|
63
63
|
return relay_mint(request, signature) if @mint_path && at?(request, @mint_path) && request.post?
|
|
64
64
|
|
|
65
65
|
authenticate!(env, request, signature)
|
|
66
|
-
@app.call(env)
|
|
66
|
+
announce(@app.call(env))
|
|
67
67
|
rescue TooLarge
|
|
68
68
|
json(413, { error: "request body too large" })
|
|
69
69
|
rescue InvalidSignature
|
|
@@ -177,9 +177,20 @@ module Patchwork
|
|
|
177
177
|
json(401, { error: message })
|
|
178
178
|
end
|
|
179
179
|
|
|
180
|
+
# Only a verified call gets the header. A request that fell through carries
|
|
181
|
+
# the consumer's own traffic, and Patchwork is not reading it.
|
|
182
|
+
def announce(response)
|
|
183
|
+
status, headers, body = response
|
|
184
|
+
[ status, headers.merge(SDK_HEADER => SDK), body ]
|
|
185
|
+
end
|
|
186
|
+
|
|
180
187
|
def json(status, payload)
|
|
181
188
|
body = JSON.generate(payload)
|
|
182
|
-
[ status, {
|
|
189
|
+
[ status, {
|
|
190
|
+
"content-type" => "application/json",
|
|
191
|
+
"content-length" => body.bytesize.to_s,
|
|
192
|
+
SDK_HEADER => SDK
|
|
193
|
+
}, [ body ] ]
|
|
183
194
|
end
|
|
184
195
|
end
|
|
185
196
|
end
|
data/lib/patchwork/rails.rb
CHANGED
|
@@ -45,6 +45,7 @@ module Patchwork
|
|
|
45
45
|
@patchwork_subject = result.subject
|
|
46
46
|
@patchwork_claims = result.claims
|
|
47
47
|
@patchwork_principal = result.principal
|
|
48
|
+
response.headers[::Patchwork::SDK_HEADER] = ::Patchwork::SDK
|
|
48
49
|
rescue ::Patchwork::StaleSignature
|
|
49
50
|
deny_patchwork_call("stale signature")
|
|
50
51
|
rescue ::Patchwork::InvalidSignature
|
data/lib/patchwork/version.rb
CHANGED
data/lib/patchwork.rb
CHANGED
|
@@ -12,6 +12,14 @@ require "patchwork/health_check"
|
|
|
12
12
|
require "patchwork/mint"
|
|
13
13
|
require "patchwork/bridge_assertion"
|
|
14
14
|
|
|
15
|
+
module Patchwork
|
|
16
|
+
# Announced on a response to a verified Patchwork call, so the platform can
|
|
17
|
+
# tell which version a workspace runs and retire an old signature label on
|
|
18
|
+
# evidence rather than a guess. Lowercase, as Rack 3 requires.
|
|
19
|
+
SDK_HEADER = "patchwork-sdk".freeze
|
|
20
|
+
SDK = "patchwork-rb/#{VERSION}".freeze
|
|
21
|
+
end
|
|
22
|
+
|
|
15
23
|
module Patchwork
|
|
16
24
|
class << self
|
|
17
25
|
def config
|