certbot 0.0.1.pre.2 → 0.0.1.pre.3
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 +4 -4
- data/README.md +10 -5
- data/app/controllers/certbot_controller.rb +3 -2
- data/lib/certbot/configuration.rb +28 -7
- data/lib/certbot/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d2f87da1860bd8451ba9a498f79bd78fa135011
|
4
|
+
data.tar.gz: ae6689ccdb9724ee9afb5ec44db769fa8b34b4ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8137c6380c07bf6b3d75f9783c584698c6607d14223261818fbb29a03e02a49e583321481417c6069d1c8e5ba2ff06dcf6eda0b218cd16a69e7434492389e019
|
7
|
+
data.tar.gz: e9e919174b4f4f6bb18c0586874c32da2b08f46312f94eb63a2089190e448a0dff66f1e60206d1d82be4f7d7dc8ee6a91206413193007cf9bc5b9ad4d3c057b8
|
data/README.md
CHANGED
@@ -19,16 +19,21 @@ http://guides.rubyonrails.org/action_controller_overview.html#force-https-protoc
|
|
19
19
|
|
20
20
|
## Configuration
|
21
21
|
|
22
|
-
By default, this library is configured via ENV variables
|
22
|
+
By default, this library is configured via pairs of ENV variables with the format:
|
23
23
|
```
|
24
|
-
|
25
|
-
|
24
|
+
/CERTBOT_TOKEN_[0-9]+/
|
25
|
+
/CERTBOT_KEY_AUTHORIZATION_[0-9]+/
|
26
|
+
```
|
27
|
+
|
28
|
+
for example:
|
29
|
+
```
|
30
|
+
CERTBOT_TOKEN_0=123123
|
31
|
+
CERTBOT_KEY_AUTHORIZATION_0=123123
|
26
32
|
```
|
27
33
|
|
28
34
|
The challenge and token can also be configured via Ruby API.
|
29
35
|
```ruby
|
30
36
|
Certbot.configure do |config|
|
31
|
-
config.
|
32
|
-
config.key_authorization = 'my_key_authorization'
|
37
|
+
config.add_token('my_challenge_token', 'my_key_authorization')
|
33
38
|
end
|
34
39
|
```
|
@@ -1,7 +1,8 @@
|
|
1
1
|
class CertbotController < Certbot::ApplicationController
|
2
2
|
def show
|
3
|
-
|
4
|
-
|
3
|
+
token = params[:token]
|
4
|
+
if certbot_config.valid_token?(token)
|
5
|
+
render text: certbot_config.key_authorization_for_token(token)
|
5
6
|
else
|
6
7
|
render nothing: true, status: 404
|
7
8
|
end
|
@@ -1,13 +1,34 @@
|
|
1
1
|
module Certbot
|
2
2
|
class Configuration
|
3
|
-
# Default: ENV['CERTBOT_TOKEN']
|
4
|
-
attr_accessor :token
|
5
|
-
# Default: ENV['CERTBOT_KEY_AUTHORIZATION']
|
6
|
-
attr_accessor :key_authorization
|
7
|
-
|
8
3
|
def initialize
|
9
|
-
@
|
10
|
-
|
4
|
+
@tokens = {}
|
5
|
+
add_tokens_from_env
|
6
|
+
end
|
7
|
+
|
8
|
+
def add_token(token, key_authorization)
|
9
|
+
@tokens[token] = key_authorization
|
10
|
+
end
|
11
|
+
|
12
|
+
def valid_token?(token)
|
13
|
+
@tokens.key?(token)
|
14
|
+
end
|
15
|
+
|
16
|
+
def key_authorization_for_token(token)
|
17
|
+
@tokens[token]
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
# TODO: raise error if missing matching authorization for token index
|
23
|
+
def add_tokens_from_env
|
24
|
+
ENV.each do |key, value|
|
25
|
+
match = key.match(/\A^CERTBOT_TOKEN_([0-9]+)\Z/)
|
26
|
+
next unless match
|
27
|
+
index = match[1]
|
28
|
+
token = value
|
29
|
+
key_authorization = ENV["CERTBOT_KEY_AUTHORIZATION_#{index}"]
|
30
|
+
add_token(token, key_authorization)
|
31
|
+
end
|
11
32
|
end
|
12
33
|
end
|
13
34
|
end
|
data/lib/certbot/version.rb
CHANGED