actionpack-cloudfront 1.0.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: dac4b315cef58b3581d910fda204426a7cd80a41
4
+ data.tar.gz: cdeaed4fa555132426f9d27942d5a583a8945358
5
+ SHA512:
6
+ metadata.gz: 89a0fa36a79acc2a8a1ce5c31cfeeb7129f71d0a9ac06767e33119bea659b63a371b30b07e15d6e3ae300c62bc7176e6e7dea45e112ba5699722443238d5b169
7
+ data.tar.gz: 2e3b6464eaf4d68542fcf4807b378d5449a2c1ee1786f693367c12f78bbe1fe6c4621a4cc601685e33a659a2bc0f2078b83b8028db361868f62a838723cb7b0c
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
@@ -0,0 +1,22 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.3.4
4
+ - 2.4.0
5
+ gemfile:
6
+ - gemfiles/rails42.gemfile
7
+ - gemfiles/rails50.gemfile
8
+ - gemfiles/rails51.gemfile
9
+ cache:
10
+ directories:
11
+ - $HOME/bin
12
+ - $HOME/.bundle
13
+ install:
14
+ - gem install bundler
15
+ - export BUNDLE_PATH=$HOME/.bundle
16
+ - bundle install
17
+ install:
18
+ - gem install bundler
19
+ - bundle --version
20
+ - bundle install
21
+ script:
22
+ - bundle exec rake test
@@ -0,0 +1,16 @@
1
+ # We use git repos so we get test directories and their support.
2
+
3
+ appraise 'rails42' do
4
+ gem 'rails', git: 'git://github.com/rails/rails.git', branch: '4-2-stable'
5
+ gem 'mocha'
6
+ end
7
+
8
+ appraise 'rails50' do
9
+ gem 'rails', git: 'git://github.com/rails/rails.git', branch: '5-0-stable'
10
+ end
11
+
12
+ appraise 'rails51' do
13
+ gem 'capybara'
14
+ gem 'puma'
15
+ gem 'rails', git: 'git://github.com/rails/rails.git', branch: '5-1-stable'
16
+ end
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
3
+
4
+ gem 'rails', git: 'git://github.com/rails/rails.git', branch: '5-1-stable'
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 CustomInk.com
4
+ Copyright (c) 2016 Ken Collins
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in
14
+ all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ THE SOFTWARE.
@@ -0,0 +1,60 @@
1
+
2
+ # Actionpack::Cloudfront
3
+
4
+ [![Build Status](https://travis-ci.org/customink/actionpack-cloudfront.svg?branch=master)](https://travis-ci.org/customink/actionpack-cloudfront)
5
+
6
+ Configure Rails' [ActionDispatch::RemoteIp](http://api.rubyonrails.org/classes/ActionDispatch/RemoteIp.html) to use Amazon CloudFront's IP ranges as trusted proxies.
7
+
8
+
9
+ ## Installation & Usage
10
+
11
+ Add this line to your Rails application's Gemfile. No other configuration is needed.
12
+
13
+ ```ruby
14
+ gem 'actionpack-cloudfront'
15
+ ```
16
+
17
+ ## How It Works
18
+
19
+ The gem works by making an API call to [https://ip-ranges.amazonaws.com/ip-ranges.json](https://ip-ranges.amazonaws.com/ip-ranges.json), selecting all `CLOUDFRONT` services and pushing each IP prefix to the following config:
20
+
21
+ ```ruby
22
+ ActionDispatch::Railtie.config.action_dispatch.trusted_proxies
23
+ ```
24
+
25
+ The API request has a timeout of 5 seconds and will only be made when the `Rails.env` is not test or development. If the timeout is reached, a local backup JSON file is used.
26
+
27
+
28
+ ## Updating Backup JSON
29
+
30
+ This uses the [jq](https://stedolan.github.io/jq/) binary to parse/clean the output.
31
+
32
+ ```shell
33
+ curl -s "https://ip-ranges.amazonaws.com/ip-ranges.json" | jq . > lib/action_pack/cloudfront/ip-ranges.json
34
+ ```
35
+
36
+ ## Contributing
37
+
38
+ We use the [Appraisal](https://github.com/thoughtbot/appraisal) gem from Thoughtbot to help us test different versions of Rails. The `appraisal rake test` subcommand runs our test suite against all Rails versions in the `Appraisal` file. So after cloning the repo, running the following commands.
39
+
40
+ ```shell
41
+ $ bundle install
42
+ $ bundle exec appraisal update
43
+ $ bundle exec appraisal rake test
44
+ ```
45
+
46
+ If you want to run the tests for a specific appraisal, use one of the names found in our `Appraisal` file. For example, the following will run our tests suite for Rails 4.2 only.
47
+
48
+ ```shell
49
+ $ bundle exec appraisal rails42 rake test
50
+ ```
51
+
52
+ ## Alternatives
53
+
54
+ * [cloudfront-rails](https://github.com/dinks/cloudfront-rails) - Leverages cached HTTP requests to Cloudfront to extend Rails' trusted proxies list thru method patching vs assigning to ActionDispatch's trusted proxies config.
55
+
56
+
57
+ ## License
58
+
59
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
60
+
@@ -0,0 +1,10 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << 'test'
6
+ t.libs << 'lib'
7
+ t.test_files = FileList['test/**/*_test.rb']
8
+ end
9
+
10
+ task default: :test
@@ -0,0 +1,23 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'action_pack/cloudfront/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'actionpack-cloudfront'
7
+ spec.version = ActionPack::Cloudfront::VERSION
8
+ spec.authors = ['Ken Collins']
9
+ spec.email = ['kcollins@customink.com']
10
+ spec.summary = "Configure ActionDispatch::RemoteIp trusted proxies for Amazon CloudFront."
11
+ spec.description = "Simple gem that adds Amazon CloudFront IP prefixes to the trusted proxies to Rails RemoteIp middleware."
12
+ spec.homepage = 'https://github.com/customink/actionpack-cloudfront'
13
+ spec.license = 'MIT'
14
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
15
+ spec.bindir = 'exe'
16
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
17
+ spec.require_paths = ['lib']
18
+ spec.add_runtime_dependency 'rails', '>= 4.2'
19
+ spec.add_development_dependency 'appraisal'
20
+ spec.add_development_dependency 'bundler'
21
+ spec.add_development_dependency 'rake'
22
+ spec.add_development_dependency 'pry'
23
+ end
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "actionpack/cloudfront"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", git: "git://github.com/rails/rails.git", branch: "4-2-stable"
6
+ gem "mocha"
7
+
8
+ gemspec path: "../"
@@ -0,0 +1,134 @@
1
+ GIT
2
+ remote: git://github.com/rails/rails.git
3
+ revision: 718d7398bc1c718b81880a3850541d98a310c9ec
4
+ branch: 4-2-stable
5
+ specs:
6
+ actionmailer (4.2.10)
7
+ actionpack (= 4.2.10)
8
+ actionview (= 4.2.10)
9
+ activejob (= 4.2.10)
10
+ mail (~> 2.5, >= 2.5.4)
11
+ rails-dom-testing (~> 1.0, >= 1.0.5)
12
+ actionpack (4.2.10)
13
+ actionview (= 4.2.10)
14
+ activesupport (= 4.2.10)
15
+ rack (~> 1.6)
16
+ rack-test (~> 0.6.2)
17
+ rails-dom-testing (~> 1.0, >= 1.0.5)
18
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
19
+ actionview (4.2.10)
20
+ activesupport (= 4.2.10)
21
+ builder (~> 3.1)
22
+ erubis (~> 2.7.0)
23
+ rails-dom-testing (~> 1.0, >= 1.0.5)
24
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
25
+ activejob (4.2.10)
26
+ activesupport (= 4.2.10)
27
+ globalid (>= 0.3.0)
28
+ activemodel (4.2.10)
29
+ activesupport (= 4.2.10)
30
+ builder (~> 3.1)
31
+ activerecord (4.2.10)
32
+ activemodel (= 4.2.10)
33
+ activesupport (= 4.2.10)
34
+ arel (~> 6.0)
35
+ activesupport (4.2.10)
36
+ i18n (~> 0.7)
37
+ minitest (~> 5.1)
38
+ thread_safe (~> 0.3, >= 0.3.4)
39
+ tzinfo (~> 1.1)
40
+ rails (4.2.10)
41
+ actionmailer (= 4.2.10)
42
+ actionpack (= 4.2.10)
43
+ actionview (= 4.2.10)
44
+ activejob (= 4.2.10)
45
+ activemodel (= 4.2.10)
46
+ activerecord (= 4.2.10)
47
+ activesupport (= 4.2.10)
48
+ bundler (>= 1.3.0, < 2.0)
49
+ railties (= 4.2.10)
50
+ sprockets-rails
51
+ railties (4.2.10)
52
+ actionpack (= 4.2.10)
53
+ activesupport (= 4.2.10)
54
+ rake (>= 0.8.7)
55
+ thor (>= 0.18.1, < 2.0)
56
+
57
+ PATH
58
+ remote: ..
59
+ specs:
60
+ actionpack-cloudfront (1.0.0)
61
+ rails (>= 4.2)
62
+
63
+ GEM
64
+ remote: https://rubygems.org/
65
+ specs:
66
+ appraisal (2.2.0)
67
+ bundler
68
+ rake
69
+ thor (>= 0.14.0)
70
+ arel (6.0.4)
71
+ builder (3.2.3)
72
+ coderay (1.1.2)
73
+ concurrent-ruby (1.0.5)
74
+ crass (1.0.3)
75
+ erubis (2.7.0)
76
+ globalid (0.4.1)
77
+ activesupport (>= 4.2.0)
78
+ i18n (0.9.1)
79
+ concurrent-ruby (~> 1.0)
80
+ loofah (2.1.1)
81
+ crass (~> 1.0.2)
82
+ nokogiri (>= 1.5.9)
83
+ mail (2.7.0)
84
+ mini_mime (>= 0.1.1)
85
+ metaclass (0.0.4)
86
+ method_source (0.9.0)
87
+ mini_mime (1.0.0)
88
+ mini_portile2 (2.3.0)
89
+ minitest (5.10.3)
90
+ mocha (1.3.0)
91
+ metaclass (~> 0.0.1)
92
+ nokogiri (1.8.1)
93
+ mini_portile2 (~> 2.3.0)
94
+ pry (0.11.3)
95
+ coderay (~> 1.1.0)
96
+ method_source (~> 0.9.0)
97
+ rack (1.6.8)
98
+ rack-test (0.6.3)
99
+ rack (>= 1.0)
100
+ rails-deprecated_sanitizer (1.0.3)
101
+ activesupport (>= 4.2.0.alpha)
102
+ rails-dom-testing (1.0.8)
103
+ activesupport (>= 4.2.0.beta, < 5.0)
104
+ nokogiri (~> 1.6)
105
+ rails-deprecated_sanitizer (>= 1.0.1)
106
+ rails-html-sanitizer (1.0.3)
107
+ loofah (~> 2.0)
108
+ rake (12.3.0)
109
+ sprockets (3.7.1)
110
+ concurrent-ruby (~> 1.0)
111
+ rack (> 1, < 3)
112
+ sprockets-rails (3.2.1)
113
+ actionpack (>= 4.0)
114
+ activesupport (>= 4.0)
115
+ sprockets (>= 3.0.0)
116
+ thor (0.20.0)
117
+ thread_safe (0.3.6)
118
+ tzinfo (1.2.4)
119
+ thread_safe (~> 0.1)
120
+
121
+ PLATFORMS
122
+ ruby
123
+
124
+ DEPENDENCIES
125
+ actionpack-cloudfront!
126
+ appraisal
127
+ bundler
128
+ mocha
129
+ pry
130
+ rails!
131
+ rake
132
+
133
+ BUNDLED WITH
134
+ 1.16.0
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", git: "git://github.com/rails/rails.git", branch: "5-0-stable"
6
+
7
+ gemspec path: "../"
@@ -0,0 +1,136 @@
1
+ GIT
2
+ remote: git://github.com/rails/rails.git
3
+ revision: dfb49730ab289d6bf3372bbaf78ed837cf6a0505
4
+ branch: 5-0-stable
5
+ specs:
6
+ actioncable (5.0.6)
7
+ actionpack (= 5.0.6)
8
+ nio4r (>= 1.2, < 3.0)
9
+ websocket-driver (~> 0.6.1)
10
+ actionmailer (5.0.6)
11
+ actionpack (= 5.0.6)
12
+ actionview (= 5.0.6)
13
+ activejob (= 5.0.6)
14
+ mail (~> 2.5, >= 2.5.4)
15
+ rails-dom-testing (~> 2.0)
16
+ actionpack (5.0.6)
17
+ actionview (= 5.0.6)
18
+ activesupport (= 5.0.6)
19
+ rack (~> 2.0)
20
+ rack-test (~> 0.6.3)
21
+ rails-dom-testing (~> 2.0)
22
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
23
+ actionview (5.0.6)
24
+ activesupport (= 5.0.6)
25
+ builder (~> 3.1)
26
+ erubis (~> 2.7.0)
27
+ rails-dom-testing (~> 2.0)
28
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
29
+ activejob (5.0.6)
30
+ activesupport (= 5.0.6)
31
+ globalid (>= 0.3.6)
32
+ activemodel (5.0.6)
33
+ activesupport (= 5.0.6)
34
+ activerecord (5.0.6)
35
+ activemodel (= 5.0.6)
36
+ activesupport (= 5.0.6)
37
+ arel (~> 7.0)
38
+ activesupport (5.0.6)
39
+ concurrent-ruby (~> 1.0, >= 1.0.2)
40
+ i18n (~> 0.7)
41
+ minitest (~> 5.1)
42
+ tzinfo (~> 1.1)
43
+ rails (5.0.6)
44
+ actioncable (= 5.0.6)
45
+ actionmailer (= 5.0.6)
46
+ actionpack (= 5.0.6)
47
+ actionview (= 5.0.6)
48
+ activejob (= 5.0.6)
49
+ activemodel (= 5.0.6)
50
+ activerecord (= 5.0.6)
51
+ activesupport (= 5.0.6)
52
+ bundler (>= 1.3.0)
53
+ railties (= 5.0.6)
54
+ sprockets-rails (>= 2.0.0)
55
+ railties (5.0.6)
56
+ actionpack (= 5.0.6)
57
+ activesupport (= 5.0.6)
58
+ method_source
59
+ rake (>= 0.8.7)
60
+ thor (>= 0.18.1, < 2.0)
61
+
62
+ PATH
63
+ remote: ..
64
+ specs:
65
+ actionpack-cloudfront (1.0.0)
66
+ rails (>= 4.2)
67
+
68
+ GEM
69
+ remote: https://rubygems.org/
70
+ specs:
71
+ appraisal (2.2.0)
72
+ bundler
73
+ rake
74
+ thor (>= 0.14.0)
75
+ arel (7.1.4)
76
+ builder (3.2.3)
77
+ coderay (1.1.2)
78
+ concurrent-ruby (1.0.5)
79
+ crass (1.0.3)
80
+ erubis (2.7.0)
81
+ globalid (0.4.1)
82
+ activesupport (>= 4.2.0)
83
+ i18n (0.9.1)
84
+ concurrent-ruby (~> 1.0)
85
+ loofah (2.1.1)
86
+ crass (~> 1.0.2)
87
+ nokogiri (>= 1.5.9)
88
+ mail (2.7.0)
89
+ mini_mime (>= 0.1.1)
90
+ method_source (0.9.0)
91
+ mini_mime (1.0.0)
92
+ mini_portile2 (2.3.0)
93
+ minitest (5.10.3)
94
+ nio4r (2.1.0)
95
+ nokogiri (1.8.1)
96
+ mini_portile2 (~> 2.3.0)
97
+ pry (0.11.3)
98
+ coderay (~> 1.1.0)
99
+ method_source (~> 0.9.0)
100
+ rack (2.0.3)
101
+ rack-test (0.6.3)
102
+ rack (>= 1.0)
103
+ rails-dom-testing (2.0.3)
104
+ activesupport (>= 4.2.0)
105
+ nokogiri (>= 1.6)
106
+ rails-html-sanitizer (1.0.3)
107
+ loofah (~> 2.0)
108
+ rake (12.3.0)
109
+ sprockets (3.7.1)
110
+ concurrent-ruby (~> 1.0)
111
+ rack (> 1, < 3)
112
+ sprockets-rails (3.2.1)
113
+ actionpack (>= 4.0)
114
+ activesupport (>= 4.0)
115
+ sprockets (>= 3.0.0)
116
+ thor (0.20.0)
117
+ thread_safe (0.3.6)
118
+ tzinfo (1.2.4)
119
+ thread_safe (~> 0.1)
120
+ websocket-driver (0.6.5)
121
+ websocket-extensions (>= 0.1.0)
122
+ websocket-extensions (0.1.3)
123
+
124
+ PLATFORMS
125
+ ruby
126
+
127
+ DEPENDENCIES
128
+ actionpack-cloudfront!
129
+ appraisal
130
+ bundler
131
+ pry
132
+ rails!
133
+ rake
134
+
135
+ BUNDLED WITH
136
+ 1.16.0