auth-centric-firewall 0.2.5 → 0.2.6

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: ca995973ab2610a6ace9e674dcaa91da867fbb2a2fe970fa7b74eda6cd783642
4
- data.tar.gz: cd90ab38577f939d0610b138784e5b1b9a4052e97195f0e5c392b84a0cdb1dbf
3
+ metadata.gz: fb8230fdd49a57f083aa3559b2fa45be4e86c8892582b629f33f336be1d5b916
4
+ data.tar.gz: 4c7241c2131193a93b941a23060c2bfec96840bf5176b7d6c2402ea4c652b2dc
5
5
  SHA512:
6
- metadata.gz: ec9f2e8d1ad101dc2dc3f5ff61e0c75fe6651b05158d8eeb3561b9b14ca2b31c718c198ea99e467709e42240ac9ce640fc091f9a0c40d07cf74181c156e5bcfb
7
- data.tar.gz: ffee61e70899f713db3bc698c24162f06f463d8d12f60fe90c06f647dd7f172c063a5cbd81126848725f0ae513e5d5fc05511a4b038f876c9088f2344cc24726
6
+ metadata.gz: d34e88880858b2f60754d6c54e85dbdd683ce60bc87b772a449c453d09d183599c62e0ec063ed1323de635d12092581e875b87f2b7336762cbbb05999a87b0b2
7
+ data.tar.gz: a43ae597272bc13758333261ef6172a9e0825a7942ff657a7343c75f75cca2f79d7271f914ea64b2fc191c52828500c4834ebb4552f511f111186d7d47426bd3
data/.rubocop.yml CHANGED
@@ -2,6 +2,9 @@ AllCops:
2
2
  TargetRubyVersion: 3.1
3
3
  NewCops: enable
4
4
 
5
+ Style/Documentation:
6
+ Enabled: false
7
+
5
8
  Style/StringLiterals:
6
9
  EnforcedStyle: single_quotes
7
10
 
@@ -11,7 +14,7 @@ Style/StringLiteralsInInterpolation:
11
14
  Layout/IndentationConsistency:
12
15
  EnforcedStyle: indented_internal_methods
13
16
 
14
- Naming/PredicateName:
17
+ Naming/PredicatePrefix:
15
18
  AllowedMethods:
16
19
  - has_access?
17
20
  - is_ipv6?
@@ -19,6 +22,7 @@ Naming/PredicateName:
19
22
  - is_
20
23
  - has_
21
24
  - have_
25
+ - does_
22
26
  MethodDefinitionMacros:
23
27
  - define_method
24
28
  - define_singleton_method
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  ## [Released]
2
2
 
3
+ ## [0.2.6] - 2026-01-03
4
+
5
+ - When checking for banned ip, pass the app id and full url path
6
+
7
+ ## [0.2.5] - 2025-11-10
8
+
9
+ - Fix Import bug
10
+
3
11
  ## [0.2.3] - 2025-09-14
4
12
 
5
13
  - Delete Captcha
@@ -16,15 +16,15 @@ module Auth
16
16
  }
17
17
 
18
18
  http = HTTP
19
- .timeout(timeout_seconds)
20
- .headers(apikey:)
21
- .post(check_code_path(id), json: payload)
19
+ .timeout(timeout_seconds)
20
+ .headers(apikey:)
21
+ .post(check_code_path(id), json: payload)
22
22
 
23
23
  case http.status
24
24
  when 202
25
- return true
25
+ true
26
26
  when 404, 406
27
- return false
27
+ false
28
28
  else
29
29
  raise Error, "#{http.status}: #{http.body}"
30
30
  end
@@ -8,9 +8,9 @@ module Auth
8
8
  return true unless enabled?
9
9
 
10
10
  http = HTTP
11
- .timeout(timeout_seconds)
12
- .headers(apikey:)
13
- .delete(delete_path(id))
11
+ .timeout(timeout_seconds)
12
+ .headers(apikey:)
13
+ .delete(delete_path(id))
14
14
 
15
15
  case http.status
16
16
  when 204
@@ -15,9 +15,9 @@ module Auth
15
15
  }
16
16
 
17
17
  http = HTTP
18
- .timeout(timeout_seconds)
19
- .headers(apikey:)
20
- .post(find_or_create_path, json: payload)
18
+ .timeout(timeout_seconds)
19
+ .headers(apikey:)
20
+ .post(find_or_create_path, json: payload)
21
21
 
22
22
  case http.status
23
23
  when 200..202
@@ -5,19 +5,23 @@ module Auth
5
5
  module Common
6
6
  module Settings
7
7
  def host
8
- @host ||= ENV['AUTH_CENTRIC_HOST'] || 'http://localhost:3003'
8
+ @host ||= ENV.fetch('AUTH_CENTRIC_HOST', 'http://localhost:3003')
9
+ end
10
+
11
+ def app_id
12
+ @app_id ||= ENV.fetch('AUTH_CENTRIC_APP_ID', '019c2077-7fb0-766b-b6cd-2a28700fd9b6')
9
13
  end
10
14
 
11
15
  def apikey
12
- @apikey ||= ENV['AUTH_CENTRIC_API_KEY'] || 'EsRx0-rLseNPjXuXj_FEa-xxzY0isi26'
16
+ @apikey ||= ENV.fetch('AUTH_CENTRIC_API_KEY', 'EsRx0-rLseNPjXuXj_FEa-xxzY0isi26')
13
17
  end
14
18
 
15
19
  def timeout_seconds
16
- @timeout_seconds ||= (ENV['AUTH_CENTRIC_TIMEOUT_SECONDS'] || 3).to_i
20
+ @timeout_seconds ||= ENV.fetch('AUTH_CENTRIC_TIMEOUT_SECONDS', 3).to_i
17
21
  end
18
22
 
19
23
  def enabled?
20
- @enabled ||= %w[true 1 yes on enabled].include?(ENV['AUTH_CENTRIC_ENABLED']&.downcase)
24
+ @enabled ||= %w[true 1 yes on enabled].include?(ENV.fetch('AUTH_CENTRIC_ENABLED', 'false')&.downcase)
21
25
  end
22
26
 
23
27
  def ip(request)
@@ -9,7 +9,6 @@ module Auth
9
9
 
10
10
  def initialize(request)
11
11
  @request = request
12
- nil
13
12
  end
14
13
 
15
14
  def as_json
@@ -3,7 +3,7 @@
3
3
  module Auth
4
4
  module Centric
5
5
  module Firewall
6
- VERSION = '0.2.5'
6
+ VERSION = '0.2.6'
7
7
  end
8
8
  end
9
9
  end
@@ -44,10 +44,16 @@ module Auth
44
44
  ip_address = InternetProtocol.new(request).ip
45
45
  return true if !forced && IGNORE_IP.include?(ip_address)
46
46
 
47
+ original_fullpath = if request.original_fullpath.length == 1
48
+ request.original_fullpath
49
+ else
50
+ request.original_fullpath[1...]
51
+ end
52
+
47
53
  http = HTTP
48
54
  .timeout(timeout_seconds)
49
55
  .headers(apikey:)
50
- .get(ip_status_path(ip_address))
56
+ .get(ip_status_path(ip_address, app_id, original_fullpath))
51
57
 
52
58
  case http.status
53
59
  when 200, 202
@@ -63,8 +69,11 @@ module Auth
63
69
 
64
70
  private
65
71
 
66
- def ip_status_path(ip_address)
67
- [host, "api/v1/internet_protocols/status?ip=#{ip_address}"].join('/')
72
+ def ip_status_path(ip_address, app_id, url)
73
+ [
74
+ host,
75
+ "api/v1/internet_protocols/status?ip=#{ip_address}&app_id=#{app_id}&url=#{url}"
76
+ ].join('/')
68
77
  end
69
78
 
70
79
  def capture_path
@@ -3,12 +3,15 @@ module Auth
3
3
  module Common
4
4
  module Settings
5
5
  @apikey: string
6
+ @app_id: string
6
7
  @enabled: bool
7
8
  @host: string
8
9
  @ip: string
9
10
  @timeout_seconds: int
10
11
 
12
+ def app_id: -> string
11
13
  def apikey: -> string
14
+
12
15
  def enabled?: -> bool
13
16
  def host: -> string
14
17
  def ip: -> string
@@ -2,6 +2,8 @@ module Auth
2
2
  module Centric
3
3
  module Firewall
4
4
  class CaptureRequest
5
+ @request: any
6
+
5
7
  def as_json: ->
6
8
  {
7
9
  ip: string,
@@ -4,6 +4,8 @@ module Auth
4
4
  class InternetProtocol
5
5
  @ip: string
6
6
 
7
+ @request: any
8
+
7
9
  def ip: -> string
8
10
  def is_ipv6?: -> bool
9
11
  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.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Saimon Lovell
@@ -92,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
92
92
  - !ruby/object:Gem::Version
93
93
  version: '0'
94
94
  requirements: []
95
- rubygems_version: 3.7.2
95
+ rubygems_version: 4.0.5
96
96
  specification_version: 4
97
97
  summary: Use artificial intelligence to find hackers.
98
98
  test_files: []