auth-centric-firewall 0.1.0 → 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: 669fd19673965861241121a8c8a1744f298e19b7116b0d96a6c2337d9a9b6a0c
4
- data.tar.gz: d13c16055743036a648bfe7a27844924da16c8a0099e0a45569b6da3752a1238
3
+ metadata.gz: fa83cf63aef7579194a4afd61f67fa84b0297a4f41f31ad75ec62bb2ae83a958
4
+ data.tar.gz: 3178e1eb516b2f0bfc1c9cc4d9dd8b8b2137e445bdeeddd4d790b4928374d918
5
5
  SHA512:
6
- metadata.gz: 2d5efc53a5a8bb3dee51368aa9720282ea44ed7aea60c412fcdb007e93945f8f6907a0581d71b5f1cc29860323996161b52c9bb2f6bc058cdfcb734c829e566d
7
- data.tar.gz: e85bacf437f529c59e17ad92518b2cc662d2516f943a38a30cd70493c843b3e3f6a4d701a27cb11bf2674b075aae09ecccc0be41e749f533e7b8a05d0db3acf3
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,5 +1,9 @@
1
1
  ## [Released]
2
2
 
3
+ ## [0.1.1, 0.1.2] - 2025-05-17
4
+
5
+ - Try to find real I.P
6
+
3
7
  ## [0.1.0] - 2025-04-14
4
8
 
5
9
  - Pass exception that has occurred
data/README.md CHANGED
@@ -4,27 +4,7 @@ Stop bad actors.
4
4
 
5
5
  ## Installation
6
6
 
7
-
8
- ```bash
9
- bundle add auth-centric-firewall
10
- ```
11
-
12
- If bundler is not being used to manage dependencies, install the gem by executing:
13
-
14
- ```bash
15
- gem install auth-centric-firewall
16
- ```
17
-
18
- ## Usage
19
-
20
- ### Env Variables
21
-
22
- ```bash
23
- AUTH_CENTRIC_ENABLED=true
24
- AUTH_CENTRIC_HOST=http://localhost:3003
25
- AUTH_CENTRIC_API_KEY=...
26
- AUTH_CENTRIC_TIMEOUT_SECONDS=3
27
- ```
7
+ See service docs in another project.
28
8
 
29
9
  ## Contributing
30
10
 
@@ -25,7 +25,7 @@ module Auth
25
25
  end
26
26
 
27
27
  def ip
28
- @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.0'
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.0
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
@@ -72,7 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
72
88
  - !ruby/object:Gem::Version
73
89
  version: '0'
74
90
  requirements: []
75
- rubygems_version: 3.6.8
91
+ rubygems_version: 3.6.9
76
92
  specification_version: 4
77
93
  summary: Use artificial intelligence to find hackers.
78
94
  test_files: []