fastly-ips 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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: '09a11f2e6134e5eea71fbf1cd0618cbde6275667250f2b4b5bdf6653da8b89e1'
4
+ data.tar.gz: 2b4cae63d0251c0d570309154aab6c9db29d36d8540436726efc26691432e6e1
5
+ SHA512:
6
+ metadata.gz: 217165fcb4ff88d6a9fbc8ecbe24d55540b8824334e89a84000d008742fff96efbf4af9d927e9f599bdef50e565d7d501de37ceb735915f6b3aa164ca38910d4
7
+ data.tar.gz: b35f6ba94c95597ed991f9a3d69cab0f4c2cbb0195ee4c452c91dd278366f030065d89a85dbc605e2350f08ccbc7a9cc1e0f3ca134112a634ba9426781b2d727
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright Kevin Sylvestre
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Fastly IPs
2
+
3
+ [![LICENSE](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/ksylvest/fastly-ips/blob/main/LICENSE)
4
+ [![RubyGems](https://img.shields.io/gem/v/fastly-ips)](https://rubygems.org/gems/fastly-ips)
5
+ [![GitHub](https://img.shields.io/badge/github-repo-blue.svg)](https://github.com/ksylvest/fastly-ips)
6
+ [![Yard](https://img.shields.io/badge/docs-site-blue.svg)](https://fastly-ips.ksylvest.com)
7
+ [![CircleCI](https://img.shields.io/circleci/build/github/ksylvest/fastly-ips)](https://circleci.com/gh/ksylvest/fastly-ips)
8
+
9
+ FastlyIPs assigns the proxy [IPv4](https://www.fastly.com/ips-v4/) and [IPv6](https://www.fastly.com/ips-v6/) fastly IPs allowing `request.remote_ip` to return back the actual IP instead of a fastly datacenter IP.
10
+
11
+ ## Installation
12
+
13
+ Configure the fastly IPs gem for any environment needed:
14
+
15
+ ```ruby
16
+ gem "fastly-ips"
17
+ ```
18
+
19
+ ```bash
20
+ $ bundle
21
+ ```
22
+
23
+ ## Usage
24
+
25
+ Use `request.remote_ip` instead of `request.ip` to properly retrieve IPs:
26
+
27
+ ```ruby
28
+ request.remote_ip
29
+ ```
data/Rakefile ADDED
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/setup'
4
+
5
+ require 'bundler/gem_tasks'
6
+
7
+ namespace :fastly do
8
+ desc 'Dump current Fastly IP ranges (v4 and v6)'
9
+ task :ips do
10
+ require 'fastly'
11
+
12
+ api = Fastly::PublicIpListApi.new
13
+ result = api.list_fastly_ips
14
+
15
+ puts '=== IPv4 ==='
16
+ result.addresses.each do |address|
17
+ puts address
18
+ end
19
+
20
+ puts
21
+
22
+ puts '=== IPv6 ==='
23
+ result.ipv6_addresses.each do |address|
24
+ puts address
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Fastly
4
+ module IPs
5
+ # Configure trusted_proxies with Fastly IPv4 and IPv6 addresses.
6
+ class Railtie < ::Rails::Railtie
7
+ initializer 'fastly-ips.configure_rails_initialization' do |app|
8
+ app.config.action_dispatch.trusted_proxies = ActionDispatch::RemoteIp::TRUSTED_PROXIES + ::Fastly::IPs::IPS
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Fastly
4
+ module IPs
5
+ VERSION = '1.0.0'
6
+ end
7
+ end
data/lib/fastly/ips.rb ADDED
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'fastly/ips/version'
4
+ require 'fastly/ips/railtie'
5
+
6
+ module Fastly
7
+ module IPs
8
+ IPS_V4 = %w[
9
+ 23.235.32.0/20
10
+ 43.249.72.0/22
11
+ 103.244.50.0/24
12
+ 103.245.222.0/23
13
+ 103.245.224.0/24
14
+ 104.156.80.0/20
15
+ 140.248.64.0/18
16
+ 140.248.128.0/17
17
+ 146.75.0.0/17
18
+ 151.101.0.0/16
19
+ 157.52.64.0/18
20
+ 167.82.0.0/17
21
+ 167.82.128.0/20
22
+ 167.82.160.0/20
23
+ 167.82.224.0/20
24
+ 172.111.64.0/18
25
+ 185.31.16.0/22
26
+ 199.27.72.0/21
27
+ 199.232.0.0/16
28
+ ].freeze
29
+
30
+ IPS_V6 = %w[
31
+ 2a04:4e40::/32
32
+ 2a04:4e42::/32
33
+ ].freeze
34
+
35
+ IPS = IPS_V4 + IPS_V6
36
+ end
37
+ end
metadata ADDED
@@ -0,0 +1,63 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fastly-ips
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Kevin Sylvestre
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: rails
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: '0'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: '0'
26
+ description: This library ensures Fastly IPs are trusted with by Ruby on Rails applications.
27
+ email:
28
+ - kevin@ksylvest.com
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - LICENSE
34
+ - README.md
35
+ - Rakefile
36
+ - lib/fastly/ips.rb
37
+ - lib/fastly/ips/railtie.rb
38
+ - lib/fastly/ips/version.rb
39
+ homepage: https://github.com/ksylvest/fastly_ips
40
+ licenses:
41
+ - MIT
42
+ metadata:
43
+ homepage_uri: https://github.com/ksylvest/fastly_ips
44
+ changelog_uri: https://github.com/ksylvest/fastly_ips/releases
45
+ rubygems_mfa_required: 'true'
46
+ rdoc_options: []
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '4.0'
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ requirements: []
60
+ rubygems_version: 4.0.7
61
+ specification_version: 4
62
+ summary: A library to configure Fastly trusted IPs.
63
+ test_files: []