acmesmith 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -4
- data/lib/acmesmith/client.rb +6 -1
- data/lib/acmesmith/command.rb +1 -1
- data/lib/acmesmith/config.rb +10 -5
- data/lib/acmesmith/post_issueing_hooks.rb +4 -8
- data/lib/acmesmith/post_issueing_hooks/base.rb +5 -17
- data/lib/acmesmith/post_issuing_hooks.rb +26 -0
- data/lib/acmesmith/{post_issueing_hooks → post_issuing_hooks}/acm.rb +2 -2
- data/lib/acmesmith/post_issuing_hooks/base.rb +21 -0
- data/lib/acmesmith/{post_issueing_hooks → post_issuing_hooks}/shell.rb +2 -2
- data/lib/acmesmith/utils/finder.rb +8 -2
- data/lib/acmesmith/version.rb +1 -1
- metadata +7 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a2e1bf037c36dc0857c9cdde9192e9dffe196a6
|
4
|
+
data.tar.gz: d04ffac3735b0af4b0e9394749ae015d9dc16eb3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 44f73438e93e201a937a769ae8481c8696144d190c238584af7cfec216616f9c76d8bfe5cb4f4fe4c3f4d107435e2e288fdfdde0394c992835c2ccb554abc088
|
7
|
+
data.tar.gz: 58efd6b4f0dc19f0602cf69f41ccf5a4659a3e58b58e8fdf4da5df09701e1da749da1d8ed69c5b407b5beb415ddcb9daea18d3122ca3dadbc883e9acf4321507
|
data/README.md
CHANGED
@@ -139,9 +139,9 @@ challenge_responders:
|
|
139
139
|
# "example.org.": "/hostedzone/DEADBEEF"
|
140
140
|
```
|
141
141
|
|
142
|
-
### Post
|
142
|
+
### Post Issuing Hooks
|
143
143
|
|
144
|
-
Post
|
144
|
+
Post issuing hooks are configurable actions that are executed
|
145
145
|
when a new certificate has been succesfully issued. The hooks are
|
146
146
|
sequentially executed in the same order as they are configured, and they
|
147
147
|
are configurable per certificate's common-name.
|
@@ -151,7 +151,7 @@ are configurable per certificate's common-name.
|
|
151
151
|
Execute specified command on a shell. Environment variable `${COMMON_NAME}` is available.
|
152
152
|
|
153
153
|
```
|
154
|
-
|
154
|
+
post_issuing_hooks:
|
155
155
|
"test.example.com":
|
156
156
|
- shell:
|
157
157
|
command: mail -s "New cert for ${COMMON_NAME} has been issued" user@example.com < /dev/null
|
@@ -167,7 +167,7 @@ post_issueing_hooks:
|
|
167
167
|
Import certificate into AWS ACM.
|
168
168
|
|
169
169
|
```
|
170
|
-
|
170
|
+
post_issuing_hooks:
|
171
171
|
"test.example.com":
|
172
172
|
- acm:
|
173
173
|
region: us-east-1 # required
|
data/lib/acmesmith/client.rb
CHANGED
@@ -103,8 +103,13 @@ module Acmesmith
|
|
103
103
|
cert
|
104
104
|
end
|
105
105
|
|
106
|
+
def post_issue_hooks(common_name)
|
107
|
+
cert = storage.get_certificate(common_name)
|
108
|
+
execute_post_issue_hooks(cert)
|
109
|
+
end
|
110
|
+
|
106
111
|
def execute_post_issue_hooks(certificate)
|
107
|
-
hooks = config.
|
112
|
+
hooks = config.post_issuing_hooks(certificate.common_name)
|
108
113
|
hooks.each do |hook|
|
109
114
|
hook.run(certificate: certificate)
|
110
115
|
end
|
data/lib/acmesmith/command.rb
CHANGED
@@ -26,7 +26,7 @@ module Acmesmith
|
|
26
26
|
puts cert.certificate.to_pem
|
27
27
|
end
|
28
28
|
|
29
|
-
desc "post-issue-hooks COMMON_NAME", "Run all post-
|
29
|
+
desc "post-issue-hooks COMMON_NAME", "Run all post-issuing hooks for common name. (for testing purpose)"
|
30
30
|
def post_issue_hooks(common_name)
|
31
31
|
client.post_issue_hooks(common_name)
|
32
32
|
end
|
data/lib/acmesmith/config.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'yaml'
|
2
2
|
require 'acmesmith/storages'
|
3
3
|
require 'acmesmith/challenge_responders'
|
4
|
-
require 'acmesmith/
|
4
|
+
require 'acmesmith/post_issuing_hooks'
|
5
5
|
|
6
6
|
module Acmesmith
|
7
7
|
class Config
|
@@ -22,6 +22,11 @@ module Acmesmith
|
|
22
22
|
unless @config['endpoint']
|
23
23
|
raise ArgumentError, "config['endpoint'] must be provided, e.g. https://acme-v01.api.letsencrypt.org/ or https://acme-staging.api.letsencrypt.org/"
|
24
24
|
end
|
25
|
+
|
26
|
+
if @config['post_issueing_hooks']
|
27
|
+
warn '!! Deprecation warning: configuration "post_issueing_hooks" is now "post_issuing_hooks" (what a typo!). It will not work in the future release.'
|
28
|
+
@config['post_issuing_hooks'] = @config.delete('post_issueing_hooks')
|
29
|
+
end
|
25
30
|
end
|
26
31
|
|
27
32
|
def [](key)
|
@@ -51,12 +56,12 @@ module Acmesmith
|
|
51
56
|
end
|
52
57
|
end
|
53
58
|
|
54
|
-
def
|
55
|
-
if @config.key?('
|
56
|
-
specs = @config['
|
59
|
+
def post_issuing_hooks(common_name)
|
60
|
+
if @config.key?('post_issuing_hooks') && @config['post_issuing_hooks'].key?(common_name)
|
61
|
+
specs = @config['post_issuing_hooks'][common_name]
|
57
62
|
specs.flat_map do |specs_sub|
|
58
63
|
specs_sub.map do |k, v|
|
59
|
-
|
64
|
+
PostIssuingHooks.find(k).new(**v.map{ |k_,v_| [k_.to_sym, v_]}.to_h)
|
60
65
|
end
|
61
66
|
end
|
62
67
|
else
|
@@ -1,9 +1,5 @@
|
|
1
|
-
require 'acmesmith/
|
1
|
+
require 'acmesmith/post_issuing_hooks'
|
2
|
+
|
3
|
+
warn "!! DEPRECATION WARNING: PostIssueingHooks is deprecated, use PostIssuingHooks (#{caller[0]})"
|
4
|
+
|
2
5
|
|
3
|
-
module Acmesmith
|
4
|
-
module PostIssueingHooks
|
5
|
-
def self.find(name)
|
6
|
-
Utils::Finder.find(self, 'acmesmith/post_issueing_hooks', name)
|
7
|
-
end
|
8
|
-
end
|
9
|
-
end
|
@@ -1,21 +1,9 @@
|
|
1
|
-
|
2
|
-
module PostIssueingHooks
|
3
|
-
class Base
|
4
|
-
attr_reader :certificate
|
5
|
-
|
6
|
-
def common_name
|
7
|
-
certificate.common_name
|
8
|
-
end
|
1
|
+
require 'acmesmith/post_issuing_hooks/base'
|
9
2
|
|
10
|
-
|
11
|
-
@certificate = certificate
|
12
|
-
execute
|
13
|
-
end
|
3
|
+
warn "!! DEPRECATION WARNING: PostIssueingHooks::Base is deprecated, use PostIssuingHooks::Base (#{caller[0]})"
|
14
4
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
end
|
5
|
+
module Acmesmith
|
6
|
+
module PostIssueingHooks
|
7
|
+
Base = PostIssuingHooks::Base
|
19
8
|
end
|
20
9
|
end
|
21
|
-
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'acmesmith/utils/finder'
|
2
|
+
|
3
|
+
module Acmesmith
|
4
|
+
module PostIssueingHooks
|
5
|
+
def self.find(name)
|
6
|
+
warn "!! DEPRECATION WARNING: PostIssueingHooks.find is deprecated, use PostIssuingHooks.find (#{caller[0]})"
|
7
|
+
return Utils::Finder.find(self, 'acmesmith/post_issueing_hooks', name)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
module PostIssuingHooks
|
12
|
+
def self.find(name)
|
13
|
+
begin
|
14
|
+
return Utils::Finder.find(self, 'acmesmith/post_issuing_hooks', name)
|
15
|
+
rescue Utils::Finder::NotFound => e
|
16
|
+
begin
|
17
|
+
klass = Utils::Finder.find(PostIssueingHooks, 'acmesmith/post_issueing_hooks', name)
|
18
|
+
warn "!! DEPRECATION WARNING (#{klass}): Placing in acmesmith/post_issueing_hooks/... is deprecated. Move to acmesmith/post_issuing_hooks/..."
|
19
|
+
return klass
|
20
|
+
rescue Utils::Finder::NotFound
|
21
|
+
raise e
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'aws-sdk'
|
2
|
-
require 'acmesmith/
|
2
|
+
require 'acmesmith/post_issuing_hooks/base'
|
3
3
|
|
4
4
|
module Acmesmith
|
5
|
-
module
|
5
|
+
module PostIssuingHooks
|
6
6
|
class Acm < Base
|
7
7
|
def initialize(certificate_arn: nil, region:)
|
8
8
|
@certificate_arn = certificate_arn
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Acmesmith
|
2
|
+
module PostIssuingHooks
|
3
|
+
class Base
|
4
|
+
attr_reader :certificate
|
5
|
+
|
6
|
+
def common_name
|
7
|
+
certificate.common_name
|
8
|
+
end
|
9
|
+
|
10
|
+
def run(certificate:)
|
11
|
+
@certificate = certificate
|
12
|
+
execute
|
13
|
+
end
|
14
|
+
|
15
|
+
def execute
|
16
|
+
raise NotImplementedError
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'open3'
|
2
|
-
require 'acmesmith/
|
2
|
+
require 'acmesmith/post_issuing_hooks/base'
|
3
3
|
|
4
4
|
module Acmesmith
|
5
|
-
module
|
5
|
+
module PostIssuingHooks
|
6
6
|
class Shell < Base
|
7
7
|
def initialize(command:, ignore_failure: false)
|
8
8
|
@command = command
|
@@ -1,7 +1,9 @@
|
|
1
1
|
module Acmesmith
|
2
2
|
module Utils
|
3
3
|
module Finder
|
4
|
-
|
4
|
+
class NotFound < StandardError; end
|
5
|
+
|
6
|
+
def self.find(const, prefix, name, error: true)
|
5
7
|
retried = false
|
6
8
|
constant_name = name.to_s.gsub(/\A.|_./) { |s| s[-1].upcase }
|
7
9
|
|
@@ -18,7 +20,11 @@ module Acmesmith
|
|
18
20
|
retry
|
19
21
|
end
|
20
22
|
|
21
|
-
|
23
|
+
if error
|
24
|
+
raise NotFound, "Couldn't find #{name.inspect} for #{const}"
|
25
|
+
else
|
26
|
+
nil
|
27
|
+
end
|
22
28
|
end
|
23
29
|
end
|
24
30
|
end
|
data/lib/acmesmith/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acmesmith
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sorah (Shota Fukumori)
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-08-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: acme-client
|
@@ -128,9 +128,11 @@ files:
|
|
128
128
|
- lib/acmesmith/command.rb
|
129
129
|
- lib/acmesmith/config.rb
|
130
130
|
- lib/acmesmith/post_issueing_hooks.rb
|
131
|
-
- lib/acmesmith/post_issueing_hooks/acm.rb
|
132
131
|
- lib/acmesmith/post_issueing_hooks/base.rb
|
133
|
-
- lib/acmesmith/
|
132
|
+
- lib/acmesmith/post_issuing_hooks.rb
|
133
|
+
- lib/acmesmith/post_issuing_hooks/acm.rb
|
134
|
+
- lib/acmesmith/post_issuing_hooks/base.rb
|
135
|
+
- lib/acmesmith/post_issuing_hooks/shell.rb
|
134
136
|
- lib/acmesmith/storages.rb
|
135
137
|
- lib/acmesmith/storages/base.rb
|
136
138
|
- lib/acmesmith/storages/filesystem.rb
|
@@ -159,7 +161,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
159
161
|
version: '0'
|
160
162
|
requirements: []
|
161
163
|
rubyforge_project:
|
162
|
-
rubygems_version: 2.6.
|
164
|
+
rubygems_version: 2.6.8
|
163
165
|
signing_key:
|
164
166
|
specification_version: 4
|
165
167
|
summary: ACME client (Let's encrypt client) to manage certificate in multi server
|