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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e287e19f12735e9c687cb6f79450e78abd78cc28e6b5c9c423444606a3b019fb
4
- data.tar.gz: b3865f72602036e7f9e02280c6bcfb48e8df7f5fdcf1a37cd2dd1588b8599b88
3
+ metadata.gz: fa83cf63aef7579194a4afd61f67fa84b0297a4f41f31ad75ec62bb2ae83a958
4
+ data.tar.gz: 3178e1eb516b2f0bfc1c9cc4d9dd8b8b2137e445bdeeddd4d790b4928374d918
5
5
  SHA512:
6
- metadata.gz: e725fadcc1372ca2363bfc0f726b8e07a70999ba37574e53e7a674988e2a1977431454c8a8d2be31760ccf0795083aea066a1df6a7b3f587e18695ecb6c5b844
7
- data.tar.gz: bd2fc5072fa375ac835f5bc3be163df97a41c1bdd21f01481e45e81e1167a5c800a98e4dfe114eca06081d5de0172eb6d502658f85bf481c4d11743806848d62
6
+ metadata.gz: 13e77b2efc5455543311dd8f46cf83fe7301803c9e240ad66b9aa4024fc551c34efd160c85c9659aff990d4313a3de13e16f2493733c7266d04b49b3ebd6b846
7
+ data.tar.gz: 1b38cd09deaf5630699d7b84f83eb48dc68cad3f89d1ee6b6b32b0a0ee0d071dca85bcb6b47c55690c0420ee55f7cf547324703ab3eb6a08dc73667efdd428c0
data/.rubocop.yml CHANGED
@@ -14,6 +14,7 @@ Layout/IndentationConsistency:
14
14
  Naming/PredicateName:
15
15
  AllowedMethods:
16
16
  - has_access?
17
+ - is_ipv6?
17
18
  NamePrefix:
18
19
  - is_
19
20
  - has_
data/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  ## [Released]
2
2
 
3
- ## [0.1.1] - 2025-05-17
3
+ ## [0.1.1, 0.1.2] - 2025-05-17
4
4
 
5
5
  - Try to find real I.P
6
6
 
@@ -25,7 +25,7 @@ module Auth
25
25
  end
26
26
 
27
27
  def ip
28
- @request.env['HTTP_X_REAL_IP'] || @request.env['HTTP_X_FORWARDED_FOR'] || @request.remote_ip
28
+ @ip ||= InternetProtocol.new(@request).ip
29
29
  end
30
30
 
31
31
  def domain
@@ -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
@@ -3,7 +3,7 @@
3
3
  module Auth
4
4
  module Centric
5
5
  module Firewall
6
- VERSION = '0.1.1'
6
+ VERSION = '0.1.2'
7
7
  end
8
8
  end
9
9
  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 = request.env['HTTP_X_FORWARDED_FOR'] || request.remote_ip
41
+ ip_address = InternetProtocol.new(request).ip
41
42
  return true if !forced && IGNORE_IP.include?(ip_address)
42
43
 
43
44
  http = HTTP
@@ -2,6 +2,7 @@ module Auth
2
2
  module Centric
3
3
  module Firewall
4
4
  class CaptureRequest
5
+ @ip: string
5
6
  @request: Net::HTTPRequest
6
7
 
7
8
  def as_json: -> { }
@@ -0,0 +1,13 @@
1
+ module Auth
2
+ module Centric
3
+ module Firewall
4
+ class InternetProtocol
5
+ @ip: string
6
+ @request: Net::HTTPRequest
7
+
8
+ def ip: -> string
9
+ def is_ipv6?: -> bool
10
+ end
11
+ end
12
+ end
13
+ end
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.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