bullion 0.4.3 → 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: f2161239051e1b4393633bd44decfe3909f4643fcda36110e0c8583385f809d5
4
- data.tar.gz: 7b273e81ff9d3301a6d6fefd674914998b3ea428dbb3c6c75d4b4667496537bd
3
+ metadata.gz: 164cf3dcab36d3365270c3e7bbfb47af7daf559d6b1d1d22764d5eb5e31d3e9d
4
+ data.tar.gz: dd530b27db7e32e710a6eb8c32728d153ab53da0443cfa3a786336ce8aef96ba
5
5
  SHA512:
6
- metadata.gz: 7d2a3b51a3a66826cb8ccc659a48f1db25e4d6ee47fb4494ce80956b7d5df7590aef672f34ce009d9a2b982c599f27368be867ea1a999e20cdb29645716a1657
7
- data.tar.gz: e2447971e639f8bc3014767cf1623e1d519b79aae820b12c12d3067b9e27a7f1caa3f02c0ed52a0380d48ca60da73627ca9a21a94f03508495fc6b05293fdd82
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.3)
4
+ bullion (0.5.0)
5
5
  dry-configurable (~> 1.1)
6
6
  httparty (~> 0.21)
7
7
  json (~> 2.6)
@@ -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
- 3 # 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.3
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