rails_hq_ip_whitelist 0.0.2 → 0.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ba8c82c02322e38d30bbd3b3474927482a6094b0
4
- data.tar.gz: de7cd514337dda1045f984515a516ad56f7993c6
3
+ metadata.gz: 407076a240656e2f204961c375000886f228920b
4
+ data.tar.gz: a1d63e78384cb7a39f597632983c30869263dadf
5
5
  SHA512:
6
- metadata.gz: f7e7bb0081225f3d926efa4d925b32cb134da2075086db2854b8f20276fbe8d265e52ac50138963d141b9491b334bf5a8c0c25bc4f21cea2c955c1417769c417
7
- data.tar.gz: 795ed6c5a79ef1634a36e53dae0a011dc60e408f24c1f6151d2881d0d2bb880cea5f9cc8541fc53702560388200561d11def697d6aed0c1bf078986791e85625
6
+ metadata.gz: 24ae2c696e12bc60c63e11088a233ddb0e8c50d8fec24e070ad4362d628418fdc7c4f8ab5297b9b64a52aaef3ad092e6cc288b5dda731ea6bcc3c269d9825fd7
7
+ data.tar.gz: 504005d4a4fae897aa17f30151be2e630715accb8c02dcc1cb02f2ac6d1f5ebfc947428d0a08291d2cdb0f8b2df930806040ea6b6f1e4abbcf58d1c9b1cabf83
@@ -1,19 +1,21 @@
1
- module IPWhitelist::Controller
2
- class IPWhitelistError < StandardError; end
3
- def self.included(base)
4
- base.before_action :check_ip_whitelist
5
- end
1
+ module IPWhitelist
2
+ module Controller
3
+ class IPWhitelistError < StandardError; end
4
+ def self.included(base)
5
+ base.before_action :check_ip_whitelist
6
+ end
6
7
 
7
- def check_ip_whitelist
8
- if current_user && current_user.respond_to?(:ip_whitelist) && current_user.ip_whitelist.present?
9
- # Since requests can come through cloudflare, try that IP first.
10
- ip = request.headers["CF-Connecting-IP"] || request.headers["REMOTE_ADDR"]
11
- return if current_user.ip_whitelist.map(&:to_s).include?(ip)
12
- raise IPWhiteListError.new(<<-MESSAGE.squish
13
- IP #{ip} is not in the whitelist for user #{current_user.username}.
14
- Whitelist: #{current_user.ip_whitelist.map(&:to_s)}
15
- MESSAGE
16
- )
8
+ def check_ip_whitelist
9
+ if current_user && current_user.respond_to?(:ip_whitelist) && current_user.ip_whitelist.present?
10
+ # Since requests can come through cloudflare, try that IP first.
11
+ ip = request.headers["CF-Connecting-IP"] || request.headers["REMOTE_ADDR"]
12
+ return if current_user.ip_whitelist.map(&:to_s).include?(ip)
13
+ raise IPWhiteListError.new(<<-MESSAGE.squish
14
+ IP #{ip} is not in the whitelist for user #{current_user.username}.
15
+ Whitelist: #{current_user.ip_whitelist.map(&:to_s)}
16
+ MESSAGE
17
+ )
18
+ end
17
19
  end
18
20
  end
19
21
  end
@@ -1,3 +1,3 @@
1
1
  module IPWhitelist
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_hq_ip_whitelist
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brendan Carney