auth-centric-firewall 0.0.7 → 0.0.9

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: 5b9400abeb47ed8c8bf280ba09f8f8a5f8fa4a95fbf28ed0197709ae3bc77f41
4
- data.tar.gz: 7bd5484e78cdd517f79de8eb8772c5ea0d7a136f439b5adb689bd2be0ac25d6c
3
+ metadata.gz: f997444c01f700674005254df0b27d7459b0c373658c34ff79b157769d376258
4
+ data.tar.gz: 8bd0e556ef46cbbc67cf36398285157df9113fd5570fea7bface6a3104aac052
5
5
  SHA512:
6
- metadata.gz: d44130ea3e21c21ab8e29637f72534a1142f912fe40aa3726c7a1c7cc7beccdedded5f15cd2a5e46c92256a51f0c653e7fe8c0ac2d37b98cbfa9ff7ac529e8ca
7
- data.tar.gz: 4f46cd0a3c71e0b1dda02479ed190c90e1c3907ac652b0ef45074b23954e25788c69ab8372d7f6f3c3bf01182cc33cf27717bff380f0682ac853aafdb225c616
6
+ metadata.gz: 611f72a5a803d4e0f89f6b45b641181a36ba52d46ff11e3485429e97b12510f4af729cbfac0fe60ee26ae1434e9d9412d3b3f7668d9c68e295389dd36d559ade
7
+ data.tar.gz: f109d3c581828a297a330d99b7ecf0451506fd3fcb871d3d0b74aa6f2b240e2cbd94498a9487f9fd91b91d20ca2d9d904a3264ecc4f89bc5e6b103628ab7c857
data/.rbenv-vars.example CHANGED
@@ -1,3 +1,4 @@
1
+ AUTH_CENTRIC_ENABLED=true
1
2
  AUTH_CENTRIC_HOST=https://...
2
3
  AUTH_CENTRIC_API_KEY=
3
4
  AUTH_CENTRIC_TIMEOUT_SECONDS=3
data/.rubocop.yml CHANGED
@@ -32,3 +32,9 @@ Layout/CaseIndentation:
32
32
  Description: 'Indentation of when in a case/when/[else/]end.'
33
33
  StyleGuide: '#indent-when-to-case'
34
34
  Enabled: false
35
+
36
+ Metrics/CyclomaticComplexity:
37
+ Max: 32
38
+
39
+ Metrics/AbcSize:
40
+ Max: 32
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.0.8] - 2025-03-29
4
+
5
+ - Added a enabled or disabled
6
+
3
7
  ## [0.0.2] - 2025-03-20
4
8
 
5
9
  - Add a 403 page
data/README.md CHANGED
@@ -20,6 +20,7 @@ gem install auth-centric-firewall
20
20
  ### Env Variables
21
21
 
22
22
  ```bash
23
+ AUTH_CENTRIC_ENABLED=true
23
24
  AUTH_CENTRIC_HOST=http://localhost:3003
24
25
  AUTH_CENTRIC_API_KEY=...
25
26
  AUTH_CENTRIC_TIMEOUT_SECONDS=3
@@ -3,7 +3,7 @@
3
3
  module Auth
4
4
  module Centric
5
5
  module Firewall
6
- VERSION = '0.0.7'
6
+ VERSION = '0.0.9'
7
7
  end
8
8
  end
9
9
  end
@@ -14,6 +14,8 @@ module Auth
14
14
  class Error < StandardError; end
15
15
 
16
16
  def log_firewall(request, forced: false)
17
+ return true unless enabled?
18
+
17
19
  unless forced
18
20
  return true if IGNORE_IP.include?(request.remote_ip)
19
21
  return true if IGNORE_REQUEST.include?(request.original_fullpath)
@@ -32,9 +34,11 @@ module Auth
32
34
  true
33
35
  end
34
36
 
35
- def valid_ip?(request)
37
+ def valid_ip?(request, forced: false)
38
+ return true unless enabled?
39
+
36
40
  ip_address = request.env['HTTP_X_FORWARDED_FOR'] || request.remote_ip
37
- return true if IGNORE_IP.include?(ip_address)
41
+ return true if !forced && IGNORE_IP.include?(ip_address)
38
42
 
39
43
  http = HTTP
40
44
  .timeout(timeout_seconds)
@@ -74,6 +78,10 @@ module Auth
74
78
  def timeout_seconds
75
79
  @timeout_seconds ||= (ENV['AUTH_CENTRIC_TIMEOUT_SECONDS'] || 3).to_i
76
80
  end
81
+
82
+ def enabled?
83
+ @enabled ||= %w[true 1 yes on enabled].include?(ENV['AUTH_CENTRIC_ENABLED']&.downcase)
84
+ end
77
85
  end
78
86
  end
79
87
  end
@@ -5,6 +5,7 @@ module Auth
5
5
 
6
6
  @host: string
7
7
  @apikey: string
8
+ @enabled: bool
8
9
  @capture_path: string
9
10
  @timeout_seconds: int
10
11
 
@@ -13,8 +14,10 @@ module Auth
13
14
 
14
15
  private
15
16
 
17
+
16
18
  def host: -> string
17
19
  def apikey: -> string
20
+ def enabled?: -> bool
18
21
  def capture_path: -> string
19
22
  def ip_status_path: -> string
20
23
  def timeout_seconds: -> int
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.0.7
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Saimon Lovell