bullion 0.4.3 → 0.5.1

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: f2161239051e1b4393633bd44decfe3909f4643fcda36110e0c8583385f809d5
4
- data.tar.gz: 7b273e81ff9d3301a6d6fefd674914998b3ea428dbb3c6c75d4b4667496537bd
3
+ metadata.gz: 56d18291c0ea53bad26341c758991fc355fd502dff0af9f63228b898581ec22e
4
+ data.tar.gz: 3cca92ceecec74f0571a84a9295ebd062baa7f8b607c45b0bca7d85032681067
5
5
  SHA512:
6
- metadata.gz: 7d2a3b51a3a66826cb8ccc659a48f1db25e4d6ee47fb4494ce80956b7d5df7590aef672f34ce009d9a2b982c599f27368be867ea1a999e20cdb29645716a1657
7
- data.tar.gz: e2447971e639f8bc3014767cf1623e1d519b79aae820b12c12d3067b9e27a7f1caa3f02c0ed52a0380d48ca60da73627ca9a21a94f03508495fc6b05293fdd82
6
+ metadata.gz: c597fba5cdec355e16599e7dce74cc388cc48bf52afee1f756d3cefd930131a359e097fb4094f7f599c99d3f0e9d62a9b6b6700ba4c458e0ada75acc239179b9
7
+ data.tar.gz: cd59c5e385d342823ddb57bffe8fdc958c158738ca61cc1d63431ed06c23819d59b1b8e16e812172dcefc43d2710fe10877004cd4b7dc1fe66ae71324eb36386
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.1)
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,10 +355,14 @@ 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"
360
362
  end
361
363
 
364
+ add_link_relation("up", uri("/authorizations/#{challenge.authorization.id}"))
365
+
362
366
  data.to_json
363
367
  rescue Bullion::Acme::Error => e
364
368
  content_type "application/problem+json"
@@ -369,6 +373,7 @@ module Bullion
369
373
  # @see https://tools.ietf.org/html/rfc8555#section-7.4.2
370
374
  post "/certificates/:id" do
371
375
  parse_acme_jwt
376
+ add_acme_headers @new_nonce
372
377
 
373
378
  order = Models::Order.where(certificate_id: params[:id]).first
374
379
  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
+ 1 # 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.1
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