action_ip_filter 0.1.1 → 0.2.0

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: eaf87646a87d44c3eb43e5d9c7f08151068ae3428405b46c034ae933adfad7ca
4
- data.tar.gz: b1d4c318d9fdba5163bac3b7ebeb8f9969718b37b526515a5861a5f509fabce1
3
+ metadata.gz: 8d061bab952784ba92d038b0a28d34418e9c360d6d6abd543621535170a9a21c
4
+ data.tar.gz: 8a57d44aa950fb7c9bc0dad8a3493add8c626df62cecea9d0a8536d5ae7bc6d6
5
5
  SHA512:
6
- metadata.gz: b666b53a5c8bd924a8489bb3b540bfe75add34d6d3e938fa5be54d0dace72d35723d6f08789b0c45944fbd1e9d3998c439963ae1b9f3c2d9e860f3e03e391669
7
- data.tar.gz: 5f3dbd4b22bad8e02f595e47417be2564efac1386bf819077301a6020626994227725cd4f5c05b7a738b3085d3092f2c1debae349b73edaca7070a7f94dfa95d
6
+ metadata.gz: 7f868950a961ac26cfebace46005f363f4cace350a63d0c58996b20966312a245794b8fe571b0abec32c216baae81e41fad39ea0eb393997348043e650263c3e
7
+ data.tar.gz: 746dc0312e87366a4d6d4e36e0bd31648255d646fb6f7d103f6e00bb4d68d1863ef4c2154737db74f3655934da81a73737b2b6a920d3338a0e8c9b69faf09afd
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.2.0] - 2025-11-28
4
+
5
+ ### Breaking Changes
6
+
7
+ - Change the interface: `s/restrict_ip/filter_ip/g`
8
+
3
9
  ## [0.1.1] - 2025-11-28
4
10
 
5
11
  ### Maintenance
data/README.md CHANGED
@@ -36,13 +36,13 @@ bundle install
36
36
 
37
37
  ### Basic Usage
38
38
 
39
- Include the concern and use `restrict_ip` to protect specific actions:
39
+ Include the concern and use `filter_ip` to protect specific actions:
40
40
 
41
41
  ```ruby
42
42
  class AdminController < ApplicationController
43
43
  include ActionIpFilter::IpFilterable
44
44
 
45
- restrict_ip :index, :show, allowed_ips: %w[192.0.2.0/24 198.51.100.1]
45
+ filter_ip :index, :show, allowed_ips: %w[192.0.2.0/24 198.51.100.1]
46
46
 
47
47
  def index
48
48
  # Only accessible from 192.0.2.0/24 or 198.51.100.1
@@ -60,14 +60,14 @@ end
60
60
 
61
61
  ### Restrict All Actions
62
62
 
63
- Use `restrict_ip_for_all` to protect all actions with optional exceptions:
63
+ Use `filter_ip_for_all` to protect all actions with optional exceptions:
64
64
 
65
65
  ```ruby
66
66
  class WebhooksController < ApplicationController
67
67
  include ActionIpFilter::IpFilterable
68
68
 
69
- restrict_ip_for_all allowed_ips: ENV["WEBHOOK_ALLOWED_IPS"].to_s.split(","),
70
- except: [:health_check]
69
+ filter_ip_for_all allowed_ips: ENV["WEBHOOK_ALLOWED_IPS"].to_s.split(","),
70
+ except: [:health_check]
71
71
 
72
72
  def stripe
73
73
  # Restricted
@@ -87,7 +87,7 @@ Pass a Proc for dynamic IP resolution:
87
87
  class SecureController < ApplicationController
88
88
  include ActionIpFilter::IpFilterable
89
89
 
90
- restrict_ip :sensitive_action,
90
+ filter_ip :sensitive_action,
91
91
  allowed_ips: -> { Rails.application.credentials.dig(:allowed_ips) || [] }
92
92
  end
93
93
  ```
@@ -100,7 +100,7 @@ Customize the response when access is denied. The block is executed via `instanc
100
100
  class ApiController < ApplicationController
101
101
  include ActionIpFilter::IpFilterable
102
102
 
103
- restrict_ip :create,
103
+ filter_ip :create,
104
104
  allowed_ips: %w[192.0.2.0/24],
105
105
  on_denied: -> { render json: { error: "Access denied from #{request.remote_ip}" }, status: :forbidden }
106
106
  end
@@ -26,7 +26,7 @@ module ActionIpFilter
26
26
  # @rbs allowed_ips: Array[String] | ^() -> Array[String]
27
27
  # @rbs on_denied: (^() -> void)?
28
28
  # @rbs return: void
29
- def restrict_ip(*actions, allowed_ips:, on_denied: nil)
29
+ def filter_ip(*actions, allowed_ips:, on_denied: nil)
30
30
  actions.flatten.each do |action|
31
31
  self.action_ip_restrictions = action_ip_restrictions.merge(action.to_sym => {allowed_ips:, on_denied:})
32
32
  before_action -> { check_ip_restriction(action) }, only: action
@@ -37,7 +37,7 @@ module ActionIpFilter
37
37
  # @rbs except: Array[Symbol]
38
38
  # @rbs on_denied: (^() -> void)?
39
39
  # @rbs return: void
40
- def restrict_ip_for_all(allowed_ips:, except: [], on_denied: nil)
40
+ def filter_ip_for_all(allowed_ips:, except: [], on_denied: nil)
41
41
  # note: hyphen is not allowed in method (i.e., action) names, so it's safe to use it as a marker
42
42
  self.action_ip_restrictions = action_ip_restrictions.merge("all-marker": {allowed_ips:, on_denied:})
43
43
  before_action :check_ip_restriction_for_all, except:
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActionIpFilter
4
- VERSION = "0.1.1" #: String
4
+ VERSION = "0.2.0" #: String
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: action_ip_filter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - SmartBank, Inc.