rack_authorised_proxy 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: 46a0e20c3751fe360cb160a74a3d1a450b1a70b1719ac60c5df91f6d20c18744
4
+ data.tar.gz: 1246d4991a6da04d7ef18ebec16aaa8619a0365f5538f0024d446c608ff9dbcb
5
+ SHA512:
6
+ metadata.gz: 209454fb458087e576b9a74b0f9db72308ab4901f0537d9d4d010b50b6171940d67626231e1f34f1c3577ce8320700f926bf08a013b972b799a1844c5081f9b1
7
+ data.tar.gz: 90ee6ef3032a0d0ece6cce7064138d88e04a58199b39b8fc8f1897d9196557b80c3a010d1a3a68adaf45ce2a91dcc5e3ced6cb9ab7bc1f963174959a366655af
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in rack_authorised_proxy.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
data/Gemfile.lock ADDED
@@ -0,0 +1,33 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ rack_authorised_proxy (0.1.0)
5
+ activesupport (>= 5.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ activesupport (6.1.4)
11
+ concurrent-ruby (~> 1.0, >= 1.0.2)
12
+ i18n (>= 1.6, < 2)
13
+ minitest (>= 5.1)
14
+ tzinfo (~> 2.0)
15
+ zeitwerk (~> 2.3)
16
+ concurrent-ruby (1.1.9)
17
+ i18n (1.8.10)
18
+ concurrent-ruby (~> 1.0)
19
+ minitest (5.14.4)
20
+ rake (13.0.6)
21
+ tzinfo (2.0.4)
22
+ concurrent-ruby (~> 1.0)
23
+ zeitwerk (2.4.2)
24
+
25
+ PLATFORMS
26
+ x86_64-linux
27
+
28
+ DEPENDENCIES
29
+ rack_authorised_proxy!
30
+ rake (~> 13.0)
31
+
32
+ BUNDLED WITH
33
+ 2.2.15
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 Joe Anderson
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,27 @@
1
+ # RackAuthorisedProxy
2
+
3
+ Only permit requests that originate from an authorised reverse proxy
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'rack_authorised_proxy', github: '12joan/rack_authorised_proxy'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle install
16
+
17
+ ## Usage
18
+
19
+ Add this line to your application's config.ru file:
20
+
21
+ ```ruby
22
+ use Rack::AuthorisedProxy
23
+ ```
24
+
25
+ ## License
26
+
27
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ task default: %i[]
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "rack_authorised_proxy"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start(__FILE__)
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
data/example/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
6
+
7
+ gem 'rack'
@@ -0,0 +1,13 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ rack (2.2.3)
5
+
6
+ PLATFORMS
7
+ x86_64-linux
8
+
9
+ DEPENDENCIES
10
+ rack
11
+
12
+ BUNDLED WITH
13
+ 2.2.15
data/example/config.ru ADDED
@@ -0,0 +1,7 @@
1
+ require 'rack'
2
+ require 'rack/lobster'
3
+ require '../lib/rack_authorised_proxy'
4
+
5
+ use Rack::AuthorisedProxy
6
+
7
+ run Rack::Lobster.new
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_support/security_utils'
4
+
5
+ module Rack
6
+ class AuthorisedProxy
7
+ VERSION = '1.0.0'
8
+
9
+ def initialize(app, options = {})
10
+ @app = app
11
+ @expected_token = options.fetch(:expected_token, ENV.fetch('PROXY_TOKEN', nil))
12
+ @header_name = options.fetch(:header_name, 'HTTP_X_PROXY_TOKEN').gsub('-', '_').upcase
13
+ @not_allowed = options.fetch(:not_allowed, proc { |env| [403, {}, ['403 Forbidden']] })
14
+ end
15
+
16
+ def call(env)
17
+ unless @expected_token.nil? || ActiveSupport::SecurityUtils.secure_compare(@expected_token, env.fetch(@header_name, ''))
18
+ return @not_allowed.call(env)
19
+ end
20
+
21
+ @app.call(env)
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/rack_authorised_proxy"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "rack_authorised_proxy"
7
+ spec.version = Rack::AuthorisedProxy::VERSION
8
+ spec.authors = ["Joe Anderson"]
9
+ spec.email = ["joe@osbert.me"]
10
+
11
+ spec.summary = "Only permit requests that originate from an authorised reverse proxy"
12
+ spec.homepage = "https://github.com/12joan/rack_authorised_proxy"
13
+ spec.license = "MIT"
14
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
15
+
16
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
17
+
18
+ spec.metadata["homepage_uri"] = spec.homepage
19
+ spec.metadata["source_code_uri"] = spec.homepage
20
+
21
+ # Specify which files should be added to the gem when it is released.
22
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
24
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
25
+ end
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ # Uncomment to register a new dependency of your gem
31
+ spec.add_dependency "activesupport", ">= 5.0"
32
+
33
+ # For more information and examples about making a new gem, checkout our
34
+ # guide at: https://bundler.io/guides/creating_gem.html
35
+ end
metadata ADDED
@@ -0,0 +1,73 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rack_authorised_proxy
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Joe Anderson
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-08-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '5.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '5.0'
27
+ description:
28
+ email:
29
+ - joe@osbert.me
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".gitignore"
35
+ - Gemfile
36
+ - Gemfile.lock
37
+ - LICENSE.txt
38
+ - README.md
39
+ - Rakefile
40
+ - bin/console
41
+ - bin/setup
42
+ - example/Gemfile
43
+ - example/Gemfile.lock
44
+ - example/config.ru
45
+ - lib/rack_authorised_proxy.rb
46
+ - rack_authorised_proxy.gemspec
47
+ homepage: https://github.com/12joan/rack_authorised_proxy
48
+ licenses:
49
+ - MIT
50
+ metadata:
51
+ allowed_push_host: https://rubygems.org
52
+ homepage_uri: https://github.com/12joan/rack_authorised_proxy
53
+ source_code_uri: https://github.com/12joan/rack_authorised_proxy
54
+ post_install_message:
55
+ rdoc_options: []
56
+ require_paths:
57
+ - lib
58
+ required_ruby_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: 2.4.0
63
+ required_rubygems_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ requirements: []
69
+ rubygems_version: 3.2.15
70
+ signing_key:
71
+ specification_version: 4
72
+ summary: Only permit requests that originate from an authorised reverse proxy
73
+ test_files: []