bullion 0.4.2 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 010c02c548debe154dae0438bf036238266630be93974cdb264983843286a56e
4
- data.tar.gz: 02412dd0d7268bcef1e19b7c863a21f7252d5a7633fecd236bc768758506169a
3
+ metadata.gz: 164cf3dcab36d3365270c3e7bbfb47af7daf559d6b1d1d22764d5eb5e31d3e9d
4
+ data.tar.gz: dd530b27db7e32e710a6eb8c32728d153ab53da0443cfa3a786336ce8aef96ba
5
5
  SHA512:
6
- metadata.gz: 65c9667eb7c624797e20c054694b7f2da90ad36ed541836e02500b0cd7bcca0359d432d3062b77dacb4c5455e11d741a91fa5d61a596b673f6bf1fe302a8968a
7
- data.tar.gz: 6bbb7cab6cf45c08899fafbf9291dbe9de7a61ac10af364d622d72eea5b857ee4889c3a4e813b7d5adac8383596c2dec9bb6bf111e2405501a7604293432f20e
6
+ metadata.gz: 1da0d24140bb16c16d440848f6dff64a8b73c846f01c882924cdffb96c16874ed2b81ad4204ee83ece321f0c9d5e449c4b22013724f9454fc37691adf2ef1ca8
7
+ data.tar.gz: a8aff288e4ba92cea77f7cbb3d07613564a59e5e525ed991581e3c51701923d6a7f04501d1582554cefcd2bd8e3081f122413ee0f302f4ee36603eb54b536ec1
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bullion (0.4.2)
4
+ bullion (0.5.0)
5
5
  dry-configurable (~> 1.1)
6
6
  httparty (~> 0.21)
7
7
  json (~> 2.6)
@@ -77,6 +77,7 @@ GEM
77
77
  kramdown (~> 2.0)
78
78
  language_server-protocol (3.17.0.3)
79
79
  mini_mime (1.1.5)
80
+ mini_portile2 (2.8.5)
80
81
  minitest (5.20.0)
81
82
  multi_json (1.15.0)
82
83
  multi_xml (0.6.0)
@@ -85,6 +86,9 @@ GEM
85
86
  mutex_m (0.2.0)
86
87
  mysql2 (0.5.5)
87
88
  nio4r (2.6.1)
89
+ nokogiri (1.15.5)
90
+ mini_portile2 (~> 2.8.2)
91
+ racc (~> 1.4)
88
92
  nokogiri (1.15.5-arm64-darwin)
89
93
  racc (~> 1.4)
90
94
  nokogiri (1.15.5-x86_64-linux)
@@ -187,6 +191,8 @@ GEM
187
191
  thor (~> 1.0)
188
192
  tilt (~> 2.0)
189
193
  yard (~> 0.9, >= 0.9.24)
194
+ sqlite3 (1.6.9)
195
+ mini_portile2 (~> 2.8.0)
190
196
  sqlite3 (1.6.9-arm64-darwin)
191
197
  sqlite3 (1.6.9-x86_64-linux)
192
198
  thor (1.3.0)
@@ -200,6 +206,7 @@ GEM
200
206
 
201
207
  PLATFORMS
202
208
  arm64-darwin-23
209
+ ruby
203
210
  x86_64-linux
204
211
 
205
212
  DEPENDENCIES
@@ -6,12 +6,39 @@ module Bullion
6
6
  module Service
7
7
  def add_acme_headers(nonce, additional: {})
8
8
  headers["Replay-Nonce"] = nonce
9
- headers["Link"] = "<#{uri("/directory")}>;rel=\"index\""
9
+ add_link_relation("index", uri("/directory"))
10
10
 
11
11
  additional.each do |name, value|
12
12
  headers[name.to_s] = value.to_s
13
13
  end
14
14
  end
15
+
16
+ def add_link_relation(type, value)
17
+ cur = link_headers_to_hash(headers["Link"])
18
+ cur[type] = value
19
+ headers["Link"] = hashed_links_to_link_headers(cur)
20
+ end
21
+
22
+ private
23
+
24
+ def link_headers_to_hash(values_string)
25
+ return {} unless values_string&.length&.positive?
26
+
27
+ values_string.split(",").to_h do |relation|
28
+ raw_value, raw_name = relation.split(";")
29
+ value = /^<(.+)>$/.match(raw_value)[1]
30
+ name = /^rel="(.+)"$/.match(raw_name)[1]
31
+ [name, value]
32
+ end
33
+ end
34
+
35
+ def hashed_links_to_link_headers(hash)
36
+ hash.reduce([]) do |acc, data|
37
+ name = "rel=\"#{data[0]}\""
38
+ value = "<#{data[1]}>"
39
+ acc << [value, name].join(";")
40
+ end.join(",")
41
+ end
15
42
  end
16
43
  end
17
44
  end
@@ -355,8 +355,11 @@ module Bullion
355
355
 
356
356
  if challenge.status == "valid"
357
357
  data[:validated] = challenge.validated
358
- order = challenge.authorization.order
358
+ authorization = challenge.authorization
359
+ authorization.update!(status: "valid") unless authorization.status == "valid"
360
+ order = authorization.order
359
361
  order.update!(status: "ready") unless order.status == "ready"
362
+ add_link_relation("up", uri("/authorizations/#{challenge.authorization.id}"))
360
363
  end
361
364
 
362
365
  data.to_json
@@ -369,6 +372,7 @@ module Bullion
369
372
  # @see https://tools.ietf.org/html/rfc8555#section-7.4.2
370
373
  post "/certificates/:id" do
371
374
  parse_acme_jwt
375
+ add_acme_headers @new_nonce
372
376
 
373
377
  order = Models::Order.where(certificate_id: params[:id]).first
374
378
  if order && order.status == "valid"
@@ -3,7 +3,7 @@
3
3
  module Bullion
4
4
  VERSION = [
5
5
  0, # major
6
- 4, # minor
7
- 2 # patch
6
+ 5, # minor
7
+ 0 # patch
8
8
  ].join(".")
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bullion
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Gnagy
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-11-29 00:00:00.000000000 Z
11
+ date: 2024-01-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-configurable