certbot 0.0.1.pre.2 → 0.0.1.pre.3

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
  SHA1:
3
- metadata.gz: ffea510708e98db7b405b9bfbf8e545a22c4677e
4
- data.tar.gz: 4c600b80462e4ee71b95a0ce84bfda86196417df
3
+ metadata.gz: 5d2f87da1860bd8451ba9a498f79bd78fa135011
4
+ data.tar.gz: ae6689ccdb9724ee9afb5ec44db769fa8b34b4ab
5
5
  SHA512:
6
- metadata.gz: c7d27a37e005752550aaa571552b76fdcf75f2951e977bd85fced953c07d0a30c8e013af08c8cbd7d35a90f315948613ac98f3f0ecc295d61471ba8e1d0a8a50
7
- data.tar.gz: bcc8efbcb798cdf7fce28957b18a05f6d2bd85f1c21376e46ddd34dd0df72d933f7eaae2422a74abf14b9c0cf0e69b9064cb3fee3646d1cdb2c0d50095dd5024
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
- CERTBOT_TOKEN = Certbot challenge token
25
- CERTBOT_KEY_AUTHORIZATION = Certbot key authorization for valid request
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.token = 'my_challenge_token'
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
- if params[:token] == certbot_config.token
4
- render text: certbot_config.key_authorization
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
- @token = ENV['CERTBOT_TOKEN']
10
- @key_authorization = ENV['CERTBOT_KEY_AUTHORIZATION']
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
@@ -1,3 +1,3 @@
1
1
  module Certbot
2
- VERSION = "0.0.1.pre.2"
2
+ VERSION = "0.0.1.pre.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: certbot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.pre.2
4
+ version: 0.0.1.pre.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - BetterUp Developers