letsencrypt_rack 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/README.md +42 -0
- data/Rakefile +6 -0
- data/letsencrypt_rack.gemspec +24 -0
- data/lib/letsencrypt_rack/middleware.rb +31 -0
- data/lib/letsencrypt_rack/railtie.rb +7 -0
- data/lib/letsencrypt_rack/version.rb +3 -0
- data/lib/letsencrypt_rack.rb +6 -0
- metadata +97 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e3469fac52f1d5f6ed12377bab11208e7e852d4f
|
4
|
+
data.tar.gz: abea16cbb68015547f9b3aa8852f37b39322bf52
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ddb71c6b920ac60ba5030e1b9f2317d392443668d4dc646ec7537a513c87cc549f1848abbdd46076fe0526300d54376acf2701aaeabc49737148d816ba18c056
|
7
|
+
data.tar.gz: 5685bb0ceb96672c334b0c718fabc7c6561a903f5ef48e2ab93e3a5c9f64a886666dc99e96debe5e004d26215263e7b376ed8e91a5580cb96fdfd60e26051f2b
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# LetsencryptRack
|
2
|
+
|
3
|
+
## Installation
|
4
|
+
|
5
|
+
Add this line to your application's Gemfile.
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
gem 'letsencrypt_rack'
|
9
|
+
```
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
You can check that the middleware is used correctly with:
|
16
|
+
|
17
|
+
$ rake middleware
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
Provide `LETSENCRYPT_RESPONSE` as environment variable within your server. For heroku you can use the toolbelt to set it:
|
22
|
+
|
23
|
+
$ heroku config:set LETSENCRYPT_RESPONSE=foo.bar
|
24
|
+
|
25
|
+
The middleware will answer all matching challenge requests:
|
26
|
+
|
27
|
+
$ curl http://your.host/.well-known/acme-challenge/foo
|
28
|
+
foo.bar
|
29
|
+
|
30
|
+
## Development
|
31
|
+
|
32
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
33
|
+
|
34
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
35
|
+
|
36
|
+
## Contributing
|
37
|
+
|
38
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/letsencrypt_rack.
|
39
|
+
|
40
|
+
## License
|
41
|
+
|
42
|
+
http://www.wtfpl.net/
|
data/Rakefile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'letsencrypt_rack/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "letsencrypt_rack"
|
8
|
+
spec.version = LetsencryptRack::VERSION
|
9
|
+
spec.authors = ["Johannes Opper"]
|
10
|
+
spec.email = ["johannes.opper@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Rack middleware to respond to letsencrypt challenges}
|
13
|
+
spec.description = %q{Rack middleware to respond to letsencrypt challenges}
|
14
|
+
spec.homepage = "https://github.com/xijo/letsencrypt_rack"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = "exe"
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.12"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
24
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module LetsencryptRack
|
2
|
+
class Middleware
|
3
|
+
def initialize(app)
|
4
|
+
@app = app
|
5
|
+
end
|
6
|
+
|
7
|
+
def call(env)
|
8
|
+
if result = challenge_answer(env)
|
9
|
+
[ 200, { 'Content-Type' => 'text/plain', 'Content-Length' => result.size.to_s }, [ result ] ]
|
10
|
+
else
|
11
|
+
@app.call(env)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def challenge_answer(env)
|
18
|
+
path = env['REQUEST_PATH'].to_s
|
19
|
+
path.start_with?('/.well-known/acme-challenge') or return
|
20
|
+
|
21
|
+
response = ENV['LETSENCRYPT_RESPONSE'].to_s
|
22
|
+
response.empty? and return 'Challenge failed - No LETSENCRYPT_RESPONSE found in env'
|
23
|
+
|
24
|
+
challenge = path[/\/.well-known\/acme-challenge\/(.*)/, 1]
|
25
|
+
challenge.empty? and return 'Challenge failed - Empty challenge request'
|
26
|
+
|
27
|
+
response.split(?.).first == challenge or return 'Challenge failed - The challenge did not match LETSENCRYPT_RESPONSE'
|
28
|
+
response
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: letsencrypt_rack
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Johannes Opper
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-05-25 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.12'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.12'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
description: Rack middleware to respond to letsencrypt challenges
|
56
|
+
email:
|
57
|
+
- johannes.opper@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".rspec"
|
64
|
+
- ".travis.yml"
|
65
|
+
- Gemfile
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- letsencrypt_rack.gemspec
|
69
|
+
- lib/letsencrypt_rack.rb
|
70
|
+
- lib/letsencrypt_rack/middleware.rb
|
71
|
+
- lib/letsencrypt_rack/railtie.rb
|
72
|
+
- lib/letsencrypt_rack/version.rb
|
73
|
+
homepage: https://github.com/xijo/letsencrypt_rack
|
74
|
+
licenses: []
|
75
|
+
metadata: {}
|
76
|
+
post_install_message:
|
77
|
+
rdoc_options: []
|
78
|
+
require_paths:
|
79
|
+
- lib
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
requirements: []
|
91
|
+
rubyforge_project:
|
92
|
+
rubygems_version: 2.6.4
|
93
|
+
signing_key:
|
94
|
+
specification_version: 4
|
95
|
+
summary: Rack middleware to respond to letsencrypt challenges
|
96
|
+
test_files: []
|
97
|
+
has_rdoc:
|