active-access 0.5.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: 2583cd41aa1f2b18374d0da7c020d85459beeeb8bbb0d9c9a44eda7941c2798d
4
+ data.tar.gz: d83db7f929fd45f7958e0fe9ccb0ab3e0e586095100851c7a486d65085967554
5
+ SHA512:
6
+ metadata.gz: b3ef3e20b4db45c1865cc17b141f884447806cc4105a88ddb9ffb5cd394e0b816e8228b8244befc5008bfba306f8b0ec7232620ad20d78d35edf127534659385
7
+ data.tar.gz: 4041a4578b572d2e6f74779a22fa03e78c1eb62a984f987f31267e4d4cd69679737fa6554f8630adfc9290328b614c831b6fe05fde99f441798037f685e04de1
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+ *.gem
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,81 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.3
3
+ DisplayStyleGuide: true
4
+ DisplayCopNames: true
5
+
6
+ #################
7
+ # [i] Overrides #
8
+ #################
9
+
10
+ CollectionMethods:
11
+ # Mapping from undesired method to desired_method
12
+ # e.g. to use `detect` over `find`:
13
+ #
14
+ # CollectionMethods:
15
+ # PreferredMethods:
16
+ # find: detect
17
+ PreferredMethods:
18
+ reduce: 'inject'
19
+ find: 'detect'
20
+ each_with_index: 'each.with_index'
21
+
22
+ # Align ends correctly.
23
+ EndAlignment:
24
+ EnforcedStyleAlignWith: variable
25
+
26
+ LineLength:
27
+ Max: 120
28
+ Exclude:
29
+ - examples/**/*
30
+
31
+ BracesAroundHashParameters:
32
+ EnforcedStyle: context_dependent
33
+
34
+ StringLiterals:
35
+ EnforcedStyle: double_quotes
36
+
37
+ #################
38
+ # Disabled cops #
39
+ #################
40
+ Metrics/ClassLength:
41
+ Enabled: false
42
+
43
+ Metrics/CyclomaticComplexity:
44
+ Enabled: false
45
+
46
+ Metrics/MethodLength:
47
+ Enabled: false
48
+
49
+ Metrics/BlockLength:
50
+ Exclude:
51
+ - spec/**/*
52
+
53
+ Style/ClassAndModuleChildren:
54
+ Enabled: false
55
+
56
+ Style/Documentation:
57
+ Enabled: false
58
+
59
+ Style/Lambda:
60
+ Enabled: false
61
+
62
+ Style/IfUnlessModifier:
63
+ Enabled: false
64
+
65
+ Style/TrailingCommaInLiteral:
66
+ Enabled: true
67
+ EnforcedStyleForMultiline: comma
68
+
69
+ Style/TrailingCommaInArguments:
70
+ Enabled: true
71
+ EnforcedStyleForMultiline: comma
72
+
73
+ Style/GuardClause:
74
+ Enabled: false
75
+
76
+ Lint/AmbiguousBlockAssociation:
77
+ Exclude:
78
+ - spec/**/*
79
+
80
+ Style/SymbolArray:
81
+ MinSize: 4
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ active_access
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ ruby-2.5.0
data/.travis.yml ADDED
@@ -0,0 +1,16 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.5.0
5
+ - 2.4.3
6
+ - 2.3.6
7
+
8
+ cache:
9
+ - bundler
10
+
11
+ branches:
12
+ only:
13
+ - master
14
+
15
+ before_install:
16
+ - gem update --system
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at georgekaraszi@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,21 @@
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
+ group :development, :test do
8
+ gem "rubocop", "~> 0.52", require: false
9
+ gem "simplecov", require: false, group: :test
10
+
11
+ gem "dotenv", "~> 2.2"
12
+ gem "faker", "~> 1.8"
13
+ gem "rake", "~> 10.4"
14
+
15
+ gem "byebug", "~> 9.0", ">= 9.0.6"
16
+ gem "pry", "~> 0.11.3"
17
+ gem "pry-byebug", "~> 3.5", ">= 3.5.1"
18
+ end
19
+
20
+ # Specify your gem's dependencies in active_access.gemspec
21
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,90 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ active-access (0.1.0)
5
+ activesupport (>= 4.2)
6
+ rack (>= 1.0)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ activesupport (5.1.5)
12
+ concurrent-ruby (~> 1.0, >= 1.0.2)
13
+ i18n (~> 0.7)
14
+ minitest (~> 5.1)
15
+ tzinfo (~> 1.1)
16
+ ast (2.4.0)
17
+ byebug (9.1.0)
18
+ coderay (1.1.2)
19
+ concurrent-ruby (1.0.5)
20
+ diff-lcs (1.3)
21
+ docile (1.1.5)
22
+ dotenv (2.2.1)
23
+ faker (1.8.7)
24
+ i18n (>= 0.7)
25
+ i18n (0.9.5)
26
+ concurrent-ruby (~> 1.0)
27
+ json (2.1.0)
28
+ method_source (0.9.0)
29
+ minitest (5.11.3)
30
+ parallel (1.12.1)
31
+ parser (2.5.0.1)
32
+ ast (~> 2.4.0)
33
+ powerpack (0.1.1)
34
+ pry (0.11.3)
35
+ coderay (~> 1.1.0)
36
+ method_source (~> 0.9.0)
37
+ pry-byebug (3.5.1)
38
+ byebug (~> 9.1)
39
+ pry (~> 0.10)
40
+ rack (2.0.4)
41
+ rainbow (3.0.0)
42
+ rake (10.5.0)
43
+ rspec (3.7.0)
44
+ rspec-core (~> 3.7.0)
45
+ rspec-expectations (~> 3.7.0)
46
+ rspec-mocks (~> 3.7.0)
47
+ rspec-core (3.7.1)
48
+ rspec-support (~> 3.7.0)
49
+ rspec-expectations (3.7.0)
50
+ diff-lcs (>= 1.2.0, < 2.0)
51
+ rspec-support (~> 3.7.0)
52
+ rspec-mocks (3.7.0)
53
+ diff-lcs (>= 1.2.0, < 2.0)
54
+ rspec-support (~> 3.7.0)
55
+ rspec-support (3.7.1)
56
+ rubocop (0.52.1)
57
+ parallel (~> 1.10)
58
+ parser (>= 2.4.0.2, < 3.0)
59
+ powerpack (~> 0.1)
60
+ rainbow (>= 2.2.2, < 4.0)
61
+ ruby-progressbar (~> 1.7)
62
+ unicode-display_width (~> 1.0, >= 1.0.1)
63
+ ruby-progressbar (1.9.0)
64
+ simplecov (0.15.1)
65
+ docile (~> 1.1.0)
66
+ json (>= 1.8, < 3)
67
+ simplecov-html (~> 0.10.0)
68
+ simplecov-html (0.10.2)
69
+ thread_safe (0.3.6)
70
+ tzinfo (1.2.5)
71
+ thread_safe (~> 0.1)
72
+ unicode-display_width (1.3.0)
73
+
74
+ PLATFORMS
75
+ ruby
76
+
77
+ DEPENDENCIES
78
+ active-access!
79
+ byebug (~> 9.0, >= 9.0.6)
80
+ dotenv (~> 2.2)
81
+ faker (~> 1.8)
82
+ pry (~> 0.11.3)
83
+ pry-byebug (~> 3.5, >= 3.5.1)
84
+ rake (~> 10.4)
85
+ rspec (~> 3.4)
86
+ rubocop (~> 0.52)
87
+ simplecov
88
+
89
+ BUNDLED WITH
90
+ 1.16.1
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 George Karaszi
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,43 @@
1
+ # ActiveAccess
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/active_access`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'active_access'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install active_access
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ 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.
30
+
31
+ 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).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/georgekaraszi@gmail.com/active_access. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
40
+
41
+ ## Code of Conduct
42
+
43
+ Everyone interacting in the ActiveAccess project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/georgekaraszi@gmail.com/active_access/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
@@ -0,0 +1,31 @@
1
+
2
+ # frozen_string_literal: true
3
+
4
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "lib"))
5
+
6
+ require "active-access/version"
7
+
8
+ Gem::Specification.new do |spec|
9
+ spec.name = "active-access"
10
+ spec.version = ActiveAccess::VERSION
11
+ spec.required_ruby_version = [">= 2.3.0", "< 2.6.0"]
12
+ spec.authors = ["George J. Protacio-Karaszi"]
13
+ spec.email = ["georgekaraszi@gmail.com"]
14
+
15
+ spec.summary = "Restrict access to your application by IP"
16
+ spec.description = "Restrict access to your application by IP"
17
+ spec.homepage = "https://github.com/GeorgeKaraszi/ActiveAccess"
18
+ spec.license = "MIT"
19
+
20
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
21
+ f.match(%r{^(test|spec|features)/})
22
+ end
23
+
24
+ spec.require_paths = ["lib"]
25
+
26
+ spec.add_dependency("activesupport", ">= 4.2")
27
+ spec.add_dependency("rack", ">= 1.0")
28
+
29
+ spec.add_development_dependency("rake", "~> 10.0")
30
+ spec.add_development_dependency("rspec", "~> 3.4")
31
+ end
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 "active_access"
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
@@ -0,0 +1,62 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "ipaddr"
4
+ require "set"
5
+ require "rack"
6
+
7
+ module ActiveAccess
8
+ class Middleware
9
+ WHITELISTED_IPS = Set.new
10
+
11
+ def self.allow_ip!(addr)
12
+ WHITELISTED_IPS << IPAddr.new(addr)
13
+ end
14
+
15
+ def initialize(app, handler = {})
16
+ @app = app
17
+ @handler = handler
18
+ refresh_whitelisted_ips
19
+ end
20
+
21
+ def call(rack_request)
22
+ if allow?(rack_request)
23
+ @app.call(rack_request)
24
+ else
25
+ [404, { "Content-Type" => "text/html", "Content-Length" => config.message.length.to_s }, [config.message]]
26
+ end
27
+ end
28
+
29
+ private
30
+
31
+ def allow?(rack_request)
32
+ request = Rack::Request.new(rack_request)
33
+ return true unless protected_domain?(request)
34
+
35
+ if request.ip.present?
36
+ ip_address = IPAddr.new(request.ip.split("%").first)
37
+ WHITELISTED_IPS.any? { |subnet| subnet.include? ip_address }
38
+ end
39
+ end
40
+
41
+ def protected_domain?(request)
42
+ return false if config.protected_domains.blank?
43
+ config.protected_domains[request.host].presence
44
+ end
45
+
46
+ # A place to fetch a cached / a list of IP's
47
+ def refresh_whitelisted_ips
48
+ config.allowed_ips.merge(["127.0.0.0/8", "::1/128"])
49
+ config.allowed_ips&.each do |ip|
50
+ begin
51
+ ActiveAccess::Middleware.allow_ip!(ip)
52
+ ensure
53
+ next # windows ruby doesn't have ipv6 support
54
+ end
55
+ end
56
+ end
57
+
58
+ def config
59
+ ActiveAccess.config
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveAccess
4
+ class Railtie < Rails::Railtie
5
+ initializer "active_access.configure_rails_initialization" do
6
+ if use_active_access?
7
+ insert_middleware
8
+ ActiveAccess.logger = Rails.logger
9
+ ActiveAccess.application_root = Rails.root.to_s
10
+ end
11
+ end
12
+
13
+ def insert_middleware
14
+ if defined? ActionDispatch::DebugExceptions
15
+ app.middleware.insert_after ActionDispatch::DebugExceptions, ActiveAccess::Middleware
16
+ else
17
+ app.middleware.use ActiveAccess::Middleware
18
+ end
19
+ end
20
+
21
+ def use_active_access?
22
+ ActiveAccess.config.enabled?
23
+ end
24
+
25
+ def app
26
+ Rails.application
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "active-access/utility/hash_mapper"
4
+
5
+ module ActiveAccess
6
+ module Utility
7
+ class Config < HashMapper
8
+ def initialize(*)
9
+ super
10
+
11
+ if protected_domains.nil?
12
+ self["protected_domains"] = {}
13
+ elsif protected_domains.is_a?(Array)
14
+ domains = protected_domains
15
+ self["protected_domains"] = {}
16
+ self.protected_domains = domains
17
+ end
18
+
19
+ self.allowed_ips = allowed_ips
20
+ self.enabled = true if enabled.nil?
21
+ self.message = "Resource Not Found" if message.nil?
22
+ end
23
+
24
+ def allowed_ips=(ip_addresses)
25
+ self["allowed_ips"] = Set.new(split_or_ship(ip_addresses))
26
+ end
27
+
28
+ def protected_domains=(domains)
29
+ return if domains.blank?
30
+ split_or_ship(domains).each { |domain| self["protected_domains"][domain.to_s] = true }
31
+ end
32
+
33
+ private
34
+
35
+ def split_or_ship(values)
36
+ values.is_a?(String) ? values.split(",").map(&:strip) : values
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,75 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveAccess
4
+ module Utility
5
+ class HashMapper < Hash
6
+ ALLOWED_SUFFIXES = %w[? =].freeze
7
+
8
+ # @OVERRIDE
9
+ # Ensure all key checks are in string format
10
+ def key?(key)
11
+ super(key.to_s)
12
+ end
13
+
14
+ # @OVERRIDE
15
+ # Check to see if missing method should call the `method_missing/3` method
16
+ def respond_to_missing?(method_name, *args)
17
+ return true if key?(method_name)
18
+ super
19
+ end
20
+
21
+ # @OVERRIDE
22
+ # Will try to resolve the called method to a stored hash KV pair
23
+ #
24
+ # Example
25
+ # config = ActiveAccess::Utility::HashMapper.new
26
+ # config.day? #=> false
27
+ # config.day = "Monday" #=> {"day" => "Monday"}
28
+ # config.day? #=> true
29
+ # config.day #=> "Monday"
30
+ def method_missing(method_name, *args, &blk)
31
+ return self.[](method_name.to_s, &blk) if key?(method_name)
32
+ name, suffix = method_name_and_suffix(method_name)
33
+ case suffix
34
+ when "="
35
+ self[name.to_s] = args.first
36
+ when "?"
37
+ !!self[name.to_s] # rubocop:disable Style/DoubleNegation
38
+ when nil
39
+ self[method_name.to_s]
40
+ else
41
+ super
42
+ end
43
+ end
44
+
45
+ # Convert all keys to proper form. This will not work with deep merging!
46
+ #
47
+ # Example:
48
+ # config = ActiveAccess::Utility::HashMapper.new #=> { "enabled" => true, ... }
49
+ # config.merge(tip: 2.00, flip: 1) #=> { "enabled" => true, "tip" => 2.00, "flip" => 1, ... }
50
+ def update!(**hash)
51
+ hash.each_pair { |key, value| self[key.to_s] = value } unless hash.empty?
52
+ self
53
+ end
54
+ alias merge! update!
55
+ alias merge update!
56
+
57
+ # @OVERRIDE
58
+ def initialize(hash = nil)
59
+ update!(hash) if hash
60
+ super
61
+ end
62
+
63
+ protected
64
+
65
+ def method_name_and_suffix(method_name)
66
+ method_name = method_name.to_s
67
+ if method_name.end_with?(*ALLOWED_SUFFIXES)
68
+ [method_name[0..-2], method_name[-1]]
69
+ else
70
+ [method_name[0..-1], nil]
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveAccess
4
+ VERSION = "0.5.0"
5
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "active_support/core_ext/object/blank"
4
+
5
+ require "active-access/utility/config"
6
+ require "active-access/middleware"
7
+ require "active-access/version"
8
+
9
+ module ActiveAccess
10
+ class << self
11
+ attr_accessor :application_root, :logger
12
+
13
+ def config
14
+ @config ||= Utility::Config.new
15
+ end
16
+
17
+ def configure
18
+ yield config
19
+ end
20
+ end
21
+ end
22
+
23
+ require "active-access/rails" if defined? Rails::Railtie
metadata ADDED
@@ -0,0 +1,124 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: active-access
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.5.0
5
+ platform: ruby
6
+ authors:
7
+ - George J. Protacio-Karaszi
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-02-22 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: '4.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '4.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rack
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '1.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '1.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.4'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.4'
69
+ description: Restrict access to your application by IP
70
+ email:
71
+ - georgekaraszi@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".rspec"
78
+ - ".rubocop.yml"
79
+ - ".ruby-gemset"
80
+ - ".ruby-version"
81
+ - ".travis.yml"
82
+ - CODE_OF_CONDUCT.md
83
+ - Gemfile
84
+ - Gemfile.lock
85
+ - LICENSE.txt
86
+ - README.md
87
+ - Rakefile
88
+ - active_access.gemspec
89
+ - bin/console
90
+ - bin/setup
91
+ - lib/active-access.rb
92
+ - lib/active-access/middleware.rb
93
+ - lib/active-access/rails.rb
94
+ - lib/active-access/utility/config.rb
95
+ - lib/active-access/utility/hash_mapper.rb
96
+ - lib/active-access/version.rb
97
+ homepage: https://github.com/GeorgeKaraszi/ActiveAccess
98
+ licenses:
99
+ - MIT
100
+ metadata: {}
101
+ post_install_message:
102
+ rdoc_options: []
103
+ require_paths:
104
+ - lib
105
+ required_ruby_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: 2.3.0
110
+ - - "<"
111
+ - !ruby/object:Gem::Version
112
+ version: 2.6.0
113
+ required_rubygems_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ requirements: []
119
+ rubyforge_project:
120
+ rubygems_version: 2.7.6
121
+ signing_key:
122
+ specification_version: 4
123
+ summary: Restrict access to your application by IP
124
+ test_files: []