auth-centric-firewall 0.1.1 → 0.1.2
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 +4 -4
- data/.rubocop.yml +1 -0
- data/CHANGELOG.md +1 -1
- data/lib/auth/centric/firewall/capture_request.rb +1 -1
- data/lib/auth/centric/firewall/internet_protocol.rb +38 -0
- data/lib/auth/centric/firewall/version.rb +1 -1
- data/lib/auth/centric/firewall.rb +2 -1
- data/sig/auth/centric/firewall/capture_request.rbs +1 -0
- data/sig/auth/centric/firewall/internet_protocol.rbs +13 -0
- metadata +17 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa83cf63aef7579194a4afd61f67fa84b0297a4f41f31ad75ec62bb2ae83a958
|
4
|
+
data.tar.gz: 3178e1eb516b2f0bfc1c9cc4d9dd8b8b2137e445bdeeddd4d790b4928374d918
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 13e77b2efc5455543311dd8f46cf83fe7301803c9e240ad66b9aa4024fc551c34efd160c85c9659aff990d4313a3de13e16f2493733c7266d04b49b3ebd6b846
|
7
|
+
data.tar.gz: 1b38cd09deaf5630699d7b84f83eb48dc68cad3f89d1ee6b6b32b0a0ee0d071dca85bcb6b47c55690c0420ee55f7cf547324703ab3eb6a08dc73667efdd428c0
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Auth
|
4
|
+
module Centric
|
5
|
+
module Firewall
|
6
|
+
# Try to find the IPv4
|
7
|
+
class InternetProtocol
|
8
|
+
require 'ipaddr'
|
9
|
+
|
10
|
+
def initialize(request)
|
11
|
+
@request = request
|
12
|
+
end
|
13
|
+
|
14
|
+
def ip
|
15
|
+
return @ip unless @ip.blank?
|
16
|
+
|
17
|
+
@ip = @request.env['HTTP_X_REAL_IP'] || @request.env['HTTP_X_FORWARDED_FOR'] || @request.remote_ip
|
18
|
+
return @ip unless @ip.include?(',')
|
19
|
+
|
20
|
+
@ip.split(',').each do |ip|
|
21
|
+
next if is_ipv6?(ip.strip)
|
22
|
+
|
23
|
+
@ip = ip.strip
|
24
|
+
break
|
25
|
+
end
|
26
|
+
|
27
|
+
@ip
|
28
|
+
end
|
29
|
+
|
30
|
+
def is_ipv6?(ip_string)
|
31
|
+
IPAddr.new(ip_string).ipv6?
|
32
|
+
rescue IPAddr::AddressFamilyError, IPAddr::InvalidAddressError
|
33
|
+
false
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -6,6 +6,7 @@ require 'http'
|
|
6
6
|
require_relative 'firewall/version'
|
7
7
|
require_relative 'firewall/constants'
|
8
8
|
require_relative 'firewall/capture_request'
|
9
|
+
require_relative 'firewall/internet_protocol'
|
9
10
|
|
10
11
|
module Auth
|
11
12
|
module Centric
|
@@ -37,7 +38,7 @@ module Auth
|
|
37
38
|
def valid_ip?(request, forced: false)
|
38
39
|
return true unless enabled?
|
39
40
|
|
40
|
-
ip_address =
|
41
|
+
ip_address = InternetProtocol.new(request).ip
|
41
42
|
return true if !forced && IGNORE_IP.include?(ip_address)
|
42
43
|
|
43
44
|
http = HTTP
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: auth-centric-firewall
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Saimon Lovell
|
@@ -23,6 +23,20 @@ dependencies:
|
|
23
23
|
- - "~>"
|
24
24
|
- !ruby/object:Gem::Version
|
25
25
|
version: '5'
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: ipaddr
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - "~>"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '1.2'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '1.2'
|
26
40
|
description: Uses A.I to analyze connections to find hackers.
|
27
41
|
email:
|
28
42
|
- staysynchronize@gmail.com
|
@@ -40,12 +54,14 @@ files:
|
|
40
54
|
- lib/auth/centric/firewall.rb
|
41
55
|
- lib/auth/centric/firewall/capture_request.rb
|
42
56
|
- lib/auth/centric/firewall/constants.rb
|
57
|
+
- lib/auth/centric/firewall/internet_protocol.rb
|
43
58
|
- lib/auth/centric/firewall/version.rb
|
44
59
|
- public/403.html
|
45
60
|
- sig/auth/centric/firewall.rbs
|
46
61
|
- sig/auth/centric/firewall/capture_request.rbs
|
47
62
|
- sig/auth/centric/firewall/check_ip.rbs
|
48
63
|
- sig/auth/centric/firewall/constants.rbs
|
64
|
+
- sig/auth/centric/firewall/internet_protocol.rbs
|
49
65
|
- sig/ignore_header_keys.rbs
|
50
66
|
- sig/ignore_ip.rbs
|
51
67
|
- sig/ignore_request.rbs
|