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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 374df53edc622840cc719b9bb341ae9ff6272fbb71cde1f71df2cb3a46819f09
4
- data.tar.gz: 5d147937164ef2fdaf16d067f586c9bf83dc13fc8b8eed578bf5ce22a4495864
3
+ metadata.gz: 564b479edcfcbad47a6b170dc219eecc6a5cd633c066f10a070631dd12583860
4
+ data.tar.gz: 0f0768a2e84d273f34eaebb0a6bef98f280dc6ff193f8ee72ded3ab6b3b9595a
5
5
  SHA512:
6
- metadata.gz: dbf196787290106a3380d963f513f40ffba9327ce7c10b33ec307fa7eb4ff1b08182b7850b63b7d05be435fdeb3b427d385f5f2e23c69281350956a29ba40832
7
- data.tar.gz: 95ee3747bab93b373d1a39ca115df1eab44a73fef3f0b49e7a2029a1d9df5418f4b7c0a23dc9197481dcf3333c9b928aeb65658639f390d74fd97a2177019521
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 |
@@ -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, { "content-type" => "application/json", "content-length" => body.bytesize.to_s }, [ body ] ]
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
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Patchwork
2
- VERSION = "0.1.5".freeze
2
+ VERSION = "0.1.6".freeze
3
3
  end
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: patchwork-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chromablue Labs