actionpack-fly 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 140984d4dc59826e134ea4bbe2af37e23eeffcc03d293638ec03d720b8261b11
4
+ data.tar.gz: 9a8b76fdfd3f26cb1568a3906f0e6d939fde9b2438f0ed1f6d986d54ec85ebbd
5
+ SHA512:
6
+ metadata.gz: b43eefacbd58df28e71cb665c7dc2ca5da1f5788bf1a25971a108621d46fd5f2b488fa905efcac248417838dde7867ff63dd41c70e48c3a1a133b79e0f08a1c7
7
+ data.tar.gz: 6e2e7755062a0377d63ce72ae74dc3d0dd4bc8710c7e9336331f20a6c0c3fd635c5b24c3c333de6ff2a6472b9457c5e98bea77aadb295c8611ee668625b46f2e
@@ -0,0 +1,29 @@
1
+ // For format details, see https://aka.ms/devcontainer.json. For config options, see the
2
+ // README at: https://github.com/devcontainers/templates/tree/main/src/ruby
3
+ {
4
+ "name": "Ruby",
5
+ // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
6
+ "image": "mcr.microsoft.com/devcontainers/ruby:0-3-bullseye",
7
+ "customizations": {
8
+ "vscode": {
9
+ "extensions": [
10
+ "Shopify.ruby-lsp"
11
+ ]
12
+ }
13
+ }
14
+
15
+ // Features to add to the dev container. More info: https://containers.dev/features.
16
+ // "features": {},
17
+
18
+ // Use 'forwardPorts' to make a list of ports inside the container available locally.
19
+ // "forwardPorts": [],
20
+
21
+ // Use 'postCreateCommand' to run commands after the container is created.
22
+ // "postCreateCommand": "ruby --version",
23
+
24
+ // Configure tool-specific properties.
25
+ // "customizations": {},
26
+
27
+ // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
28
+ // "remoteUser": "root"
29
+ }
@@ -0,0 +1,35 @@
1
+ # This workflow uses actions that are not certified by GitHub.
2
+ # They are provided by a third-party and are governed by
3
+ # separate terms of service, privacy policy, and support
4
+ # documentation.
5
+ # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
+ # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
+
8
+ name: Ruby
9
+
10
+ on:
11
+ push:
12
+ branches: [ "master" ]
13
+ pull_request:
14
+ branches: [ "master" ]
15
+
16
+ permissions:
17
+ contents: read
18
+
19
+ jobs:
20
+ test:
21
+
22
+ runs-on: ubuntu-latest
23
+ strategy:
24
+ matrix:
25
+ ruby-version: ['2.7', '3.0', '3.1', '3.2']
26
+
27
+ steps:
28
+ - uses: actions/checkout@v3
29
+ - name: Set up Ruby
30
+ uses: ruby/setup-ruby@v1
31
+ with:
32
+ ruby-version: ${{ matrix.ruby-version }}
33
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
34
+ - name: Run tests
35
+ run: bundle exec rspec
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ actionpack-fly-*.gem
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
3
+
4
+ gem 'rails', '~> 7.0'
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 Peter Cai
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,33 @@
1
+
2
+ # Actionpack::Fly
3
+
4
+ ![Build Status](https://github.com/pcai/actionpack-fly/actions/workflows/ruby.yml/badge.svg)
5
+
6
+ Simple gem that extends Rails `request.remote_ip` to default to Fly's `Fly-Client-IP` header. More about [Fly HTTP Request Headers](https://fly.io/docs/reference/runtime-environment/#fly-client-ip) and why we choose to trust `Fly-Client-IP`.
7
+
8
+
9
+ ## Installation
10
+
11
+ Add this line to your Rails application's Gemfile:
12
+
13
+ ```ruby
14
+ gem 'actionpack-fly'
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ None! Just install and feel confident that `request.remote_ip` is doing its job.
20
+
21
+
22
+ ## Contributing
23
+
24
+
25
+
26
+
27
+ ## License
28
+
29
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
30
+
31
+ ## Credits
32
+
33
+ Forked from https://github.com/customink/actionpack-cloudflare
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new { |t| t.pattern = "spec/**/*_spec.rb" }
5
+
6
+ task default: :spec
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "action_pack/fly/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "actionpack-fly"
8
+ spec.version = ActionPack::Fly::VERSION
9
+ spec.authors = ["Peter Cai"]
10
+ spec.email = ["hello@petercai.com"]
11
+ spec.summary =
12
+ "Allow Rails request.remote_ip to defer to Fly's connecting IP address."
13
+ spec.description =
14
+ "Simple gem that extends Rails `request.remote_ip` to default to Fly's `Fly-Client-IP` header."
15
+ spec.required_ruby_version = ">= 2.7.0"
16
+ spec.homepage = "https://github.com/pcai/actionpack-fly"
17
+ spec.license = "MIT"
18
+ spec.files =
19
+ `git ls-files -z`.split("\x0")
20
+ .reject { |f| f.match(%r{^(test|spec|features)/}) }
21
+ spec.bindir = "exe"
22
+ spec.require_paths = ["lib"]
23
+ spec.add_runtime_dependency "actionpack", ">= 6.0", "< 8.0"
24
+ spec.add_development_dependency "rspec", "~> 3.12"
25
+ spec.metadata["rubygems_mfa_required"] = "true"
26
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "actionpack/fly"
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
data/bin/setup ADDED
@@ -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,17 @@
1
+ module ActionPack
2
+ module Fly
3
+ module Request
4
+ def remote_ip
5
+ remote_ip_fly || super
6
+ end
7
+
8
+ private
9
+
10
+ def remote_ip_fly
11
+ @env["HTTP_FLY_CLIENT_IP"]
12
+ end
13
+ end
14
+ end
15
+ end
16
+
17
+ ActionDispatch::Request.class_eval { prepend ActionPack::Fly::Request }
@@ -0,0 +1,5 @@
1
+ module ActionPack
2
+ module Fly
3
+ VERSION = "1.0.0".freeze
4
+ end
5
+ end
@@ -0,0 +1,10 @@
1
+ require "action_pack"
2
+ require "action_dispatch"
3
+ require "action_dispatch/http/request"
4
+ require "action_pack/fly/version"
5
+ require "action_pack/fly/request"
6
+
7
+ module ActionPack
8
+ module Fly
9
+ end
10
+ end
@@ -0,0 +1 @@
1
+ require "action_pack/fly"
metadata ADDED
@@ -0,0 +1,93 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: actionpack-fly
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Peter Cai
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2023-04-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: actionpack
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '6.0'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '8.0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '6.0'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '8.0'
33
+ - !ruby/object:Gem::Dependency
34
+ name: rspec
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '3.12'
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '3.12'
47
+ description: Simple gem that extends Rails `request.remote_ip` to default to Fly's
48
+ `Fly-Client-IP` header.
49
+ email:
50
+ - hello@petercai.com
51
+ executables: []
52
+ extensions: []
53
+ extra_rdoc_files: []
54
+ files:
55
+ - ".devcontainer/devcontainer.json"
56
+ - ".github/workflows/ruby.yml"
57
+ - ".gitignore"
58
+ - Gemfile
59
+ - LICENSE.txt
60
+ - README.md
61
+ - Rakefile
62
+ - actionpack-fly.gemspec
63
+ - bin/console
64
+ - bin/setup
65
+ - lib/action_pack/fly.rb
66
+ - lib/action_pack/fly/request.rb
67
+ - lib/action_pack/fly/version.rb
68
+ - lib/actionpack-fly.rb
69
+ homepage: https://github.com/pcai/actionpack-fly
70
+ licenses:
71
+ - MIT
72
+ metadata:
73
+ rubygems_mfa_required: 'true'
74
+ post_install_message:
75
+ rdoc_options: []
76
+ require_paths:
77
+ - lib
78
+ required_ruby_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: 2.7.0
83
+ required_rubygems_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ requirements: []
89
+ rubygems_version: 3.4.6
90
+ signing_key:
91
+ specification_version: 4
92
+ summary: Allow Rails request.remote_ip to defer to Fly's connecting IP address.
93
+ test_files: []