bullion 0.3.0 → 0.3.1

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: f7e5e7935b8ed90f7e8e6695215b039507272a2db3ab1ed8919b0ae9abef1823
4
- data.tar.gz: 81e4de3cc1fe7e876c487c7edb0fd3e775125d841e16ff3948fafd5e1d5adec2
3
+ metadata.gz: f1897a626efbdecba9680874c7c3266b74bcfdbbe75e6b9646876cdac0951166
4
+ data.tar.gz: 9615ce0ee849c308eb6c0e19ca265e08f2794decb0b204fe1d3b4ed0896e7705
5
5
  SHA512:
6
- metadata.gz: e8d9a743a1b81df4ee26858d7ece2b43c77070568f01298d35c4b2eef78f6cac6a1ecab89e232d18e5321f81b4382ac331a3242d11771bd954de64b5a9a16961
7
- data.tar.gz: 628f70c629f53e09424c59a5553c81dbb172d3d57fa117e76c74d861e8cd1ad9a0a47d52db52609d17d2da78b6c50d7fc533007966a532d2e4acc9f04dab79d6
6
+ metadata.gz: f78395c368c1b52af2cf043615c89925697f48faf40d7fa5623198b44b14eece6085d7a49d00bbaff53c7e4d24dafe2fb8fb65fc7f788a872de98c3a75e6aa2a
7
+ data.tar.gz: d89899a9513543bbba121496a4c214f96ee327e98d7993c5806b436a32e2c16256dc9296f82fa74ab3a558ddaba8755dd895c8534a07e77580f5b964efbad118
data/.rspec CHANGED
@@ -1,3 +1,2 @@
1
1
  --format documentation
2
2
  --color
3
- --require spec_helper
data/Dockerfile CHANGED
@@ -1,34 +1,25 @@
1
- FROM ruby:3.1-alpine AS build
1
+ FROM ruby:3.1 AS build
2
2
 
3
3
  ENV RACK_ENV=development
4
4
 
5
5
  COPY . /build
6
6
 
7
- RUN apk --no-cache upgrade \
8
- && apk --no-cache add git mariadb-client mariadb-connector-c \
9
- runit sqlite-dev \
10
- && apk --no-cache add --virtual build-dependencies \
11
- build-base mariadb-dev
7
+ RUN apt-get update && apt-get upgrade -y && apt-get install -y libsqlite3-dev sqlite3 curl libsodium-dev
12
8
 
13
- RUN apk add build-base \
14
- && cd /build \
9
+ RUN cd /build \
15
10
  && gem build bullion.gemspec \
16
11
  && mv bullion*.gem /bullion.gem
17
12
 
18
13
  WORKDIR /build
19
14
 
20
- FROM ruby:3.1-alpine
15
+ FROM ruby:3.1
21
16
  LABEL maintainer="Jonathan Gnagy <jonathan.gnagy@gmail.com>"
22
17
 
23
18
  ENV BULLION_PORT=9292
24
19
  ENV BULLION_ENVIRONMENT=development
25
20
  ENV DATABASE_URL=sqlite3:///tmp/bullion.db
26
21
 
27
- RUN apk --no-cache upgrade \
28
- && apk --no-cache add git mariadb-client mariadb-connector-c \
29
- runit sqlite-dev \
30
- && apk --no-cache add --virtual build-dependencies \
31
- build-base mariadb-dev
22
+ RUN apt-get update && apt-get upgrade -y && apt-get -y install libsqlite3-dev sqlite3 curl libsodium-dev
32
23
 
33
24
  RUN mkdir /app
34
25
 
@@ -47,8 +38,7 @@ RUN chmod +x /entrypoint.sh \
47
38
 
48
39
  WORKDIR /app
49
40
 
50
- RUN gem install bullion.gem \
51
- && apk del build-dependencies
41
+ RUN gem install bullion.gem
52
42
 
53
43
  USER nobody
54
44
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bullion (0.3.0)
4
+ bullion (0.3.1)
5
5
  httparty (~> 0.18)
6
6
  json (~> 2.6)
7
7
  jwt (~> 2.4)
data/README.md CHANGED
@@ -36,7 +36,7 @@ Whether run locally or via Docker, the following environment variables configure
36
36
  | `CA_CERT_PATH` | `$CA_DIR/tls.crt` | Public cert for Bullion. If Bullion is an intermediate CA, you'll want to include the root CA's public cert in this file as well the signed cert for Bullion. |
37
37
  | `CA_DOMAINS` | `example.com` | A comma-delimited list of domains for which Bullion will sign certificate requests. Subdomains are automatically allowed. Certificates containing other domains will be rejected. |
38
38
  | `CERT_VALIDITY_DURATION` | `7776000` | How long should issued certs be valid (in seconds)? Default is 90 days. |
39
- | `DATABASE_URL` | _None_ | **(Required)** A shorthand for telling Bullion how to connect to a database. Acceptable URLs will either being with `sqlite3:` or [`mysql2://`](https://github.com/brianmario/mysql2#using-active-records-database_url). |
39
+ | `DATABASE_URL` | _None_ | **(Required)** A shorthand for telling Bullion how to connect to a database. Acceptable URLs will either begin with `sqlite3:` or [`mysql2://`](https://github.com/brianmario/mysql2#using-active-records-database_url). |
40
40
  | `DNS01_NAMESERVERS` | _None_ | A comma-delimited list of nameservers to use for resolving [DNS-01](https://letsencrypt.org/docs/challenge-types/#dns-01-challenge) challenges. Usually you'll want this to be set to your _internal_ nameservers so internal names resolve correctly. When not set, it'll use the host's DNS. |
41
41
  | `LOG_LEVEL` | `warn` | Log level for Bullion. Supported levels (starting with the noisiest) are debug, info, warn, error, and fatal. |
42
42
  | `BULLION_PORT` | `9292` | TCP port Bullion will listen on. |
data/Rakefile CHANGED
@@ -20,7 +20,14 @@ namespace :db do
20
20
  end
21
21
  end
22
22
 
23
- RSpec::Core::RakeTask.new(:spec)
23
+ RSpec::Core::RakeTask.new(:spec) do |t|
24
+ t.exclude_pattern = "spec/integration/**{,/*/**}/*_spec.rb"
25
+ t.rspec_opts = "--require spec_helper"
26
+ end
27
+ RSpec::Core::RakeTask.new(:integration_testing) do |t|
28
+ t.pattern = "spec/integration/**{,/*/**}/*_spec.rb"
29
+ t.rspec_opts = "--require integration_helper"
30
+ end
24
31
  RuboCop::RakeTask.new(:rubocop)
25
32
  YARD::Rake::YardocTask.new
26
33
 
@@ -64,7 +71,14 @@ task :prep do
64
71
  end
65
72
 
66
73
  task :demo do
67
- system("rackup -D -P #{File.expand_path(".")}/tmp/daemon.pid")
74
+ rack_env = "test"
75
+ database_url = "sqlite3:#{File.expand_path(".")}/tmp/db/#{rack_env}.sqlite3"
76
+ system("RACK_ENV=\"#{rack_env}\" DATABASE_URL=\"#{database_url}\" bundle exec rake db:migrate")
77
+ system(
78
+ "RACK_ENV=\"#{rack_env}\" DATABASE_URL=\"#{database_url}\" " \
79
+ "LOG_LEVEL='#{ENV.fetch("LOG_LEVEL", "info")}' " \
80
+ "rackup -D -P #{File.expand_path(".")}/tmp/daemon.pid"
81
+ )
68
82
  end
69
83
 
70
84
  task :foreground_demo do
@@ -85,10 +99,11 @@ task :cleanup do
85
99
  end
86
100
  end
87
101
 
88
- Rake::Task["spec"].enhance(["cleanup"])
102
+ Rake::Task["integration_testing"].enhance(["cleanup"])
89
103
 
90
- task default: %i[prep db:migrate demo spec rubocop]
104
+ task test: %i[prep db:migrate spec demo integration_testing]
105
+ task unit: %i[prep db:migrate spec]
91
106
 
92
- task test: %i[prep db:migrate demo spec]
107
+ task default: %i[test rubocop yard]
93
108
 
94
109
  task local_demo: %i[prep db:migrate foreground_demo]
@@ -53,7 +53,7 @@ module Bullion
53
53
  # rubocop:enable Metrics/MethodLength
54
54
 
55
55
  def identifier
56
- challenge.authorization.identifier["value"]
56
+ challenge.identifier
57
57
  end
58
58
  end
59
59
  end
@@ -23,29 +23,26 @@ module Bullion
23
23
  Base64.urlsafe_encode64(digest).sub(/[\s=]*\z/, "")
24
24
  end
25
25
 
26
- def dns_value
27
- name = "_acme-challenge.#{identifier}"
26
+ def dns_name
27
+ "_acme-challenge.#{identifier}"
28
+ end
28
29
 
30
+ def dns_value
29
31
  # Randomly select a nameserver to pull the TXT record
30
32
  nameserver = NAMESERVERS.sample
31
33
 
32
- LOGGER.debug "Looking up #{name}"
33
- records = records_for(name, nameserver)
34
- raise "Failed to find records for #{name}" unless records
34
+ LOGGER.debug "Looking up #{dns_name}"
35
+ records = records_for(dns_name, nameserver)
36
+ raise "Failed to find records for #{dns_name}" unless records
35
37
 
36
38
  record = records.map(&:strings).flatten.first
37
- LOGGER.debug "Resolved #{name} to value #{record}"
39
+ LOGGER.debug "Resolved #{dns_name} to value #{record}"
38
40
  record
39
- rescue Resolv::ResolvError
40
- msg = ["Resolution error for #{name}"]
41
+ rescue StandardError => e
42
+ msg = ["Resolution error '#{e.message}' for #{dns_name}"]
41
43
  msg << "via #{nameserver}" if nameserver
42
44
  LOGGER.info msg.join(" ")
43
45
  false
44
- rescue StandardError => e
45
- msg = ["Error '#{e.message}' for #{name}"]
46
- msg << "with #{nameserver}" if nameserver
47
- LOGGER.warn msg.join(" ")
48
- false
49
46
  end
50
47
 
51
48
  def records_for(name, nameserver = nil)
@@ -4,8 +4,8 @@ module Bullion
4
4
  module Models
5
5
  # ACMEv2 Account model
6
6
  class Account < ActiveRecord::Base
7
- serialize :contacts, Array
8
- serialize :public_key, Hash
7
+ serialize :contacts, JSON
8
+ serialize :public_key, JSON
9
9
 
10
10
  validates_uniqueness_of :public_key
11
11
 
@@ -4,7 +4,7 @@ module Bullion
4
4
  module Models
5
5
  # ACMEv2 Authorization model
6
6
  class Authorization < ActiveRecord::Base
7
- serialize :identifier, Hash
7
+ serialize :identifier, JSON
8
8
 
9
9
  after_initialize :init_values, unless: :persisted?
10
10
 
@@ -4,7 +4,7 @@ module Bullion
4
4
  module Models
5
5
  # SSL Certificate model
6
6
  class Certificate < ActiveRecord::Base
7
- serialize :alternate_names
7
+ serialize :alternate_names, JSON
8
8
 
9
9
  after_initialize :init_values, unless: :persisted?
10
10
 
@@ -11,6 +11,13 @@ module Bullion
11
11
  validates :acme_type, inclusion: { in: %w[http-01 dns-01] }
12
12
  validates :status, inclusion: { in: %w[invalid pending processing valid] }
13
13
 
14
+ scope :dns01, -> { where(acme_type: "dns-01") }
15
+ scope :http01, -> { where(acme_type: "http-01") }
16
+
17
+ def identifier
18
+ authorization.identifier["value"]
19
+ end
20
+
14
21
  def init_values
15
22
  self.expires ||= Time.now + (60 * 60)
16
23
  self.token ||= SecureRandom.alphanumeric(48)
@@ -4,7 +4,7 @@ module Bullion
4
4
  module Models
5
5
  # ACMEv2 Order model
6
6
  class Order < ActiveRecord::Base
7
- serialize :identifiers, Array
7
+ serialize :identifiers, JSON
8
8
 
9
9
  after_initialize :init_values, unless: :persisted?
10
10
 
@@ -4,6 +4,6 @@ module Bullion
4
4
  VERSION = [
5
5
  0, # major
6
6
  3, # minor
7
- 0 # patch
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.3.0
4
+ version: 0.3.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: 2022-07-18 00:00:00.000000000 Z
11
+ date: 2022-07-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty