Skip to content

Commit

Permalink
Merge pull request #2484 from cyberark/cyberark/ONYX-16929
Browse files Browse the repository at this point in the history
Rename the TrustedProxyFilter class to IsIpTrusted
  • Loading branch information
ajay-vel authored Feb 10, 2022
2 parents 05ddcb9 + 19eeb05 commit d9c17cd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion config/initializers/trusted_proxies.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
disable_cache = config.respond_to?(:conjur_disable_trusted_proxies_cache) &&
config.conjur_disable_trusted_proxies_cache

Rack::Request.ip_filter = Conjur::TrustedProxyFilter.new(
Rack::Request.ip_filter = Conjur::IsIpTrusted.new(
config: Rails.application.config.conjur_config,
disable_cache: disable_cache
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# frozen_string_literal: true

module Conjur
# TrustedProxyFilter wraps the default Rack IP filtering. This allows
# IsIpTrusted wraps the default Rack IP filtering. This allows
# the trusted proxies to be configured using the environment variable,
# `TRUSTED_PROXIES`.
#
# The value of `TRUSTED_PROXIES` must be a comma-separated list of IP
# addresses or IP address ranges using CIDR notation.
#
# Example: TRUSTED_PROXIES=4.4.4.4,192.168.100.0/24
class TrustedProxyFilter
class IsIpTrusted
def initialize(config:, disable_cache: true)
@config = config
@disable_cache = disable_cache
Expand Down Expand Up @@ -47,8 +47,8 @@ def configured_trusted_proxies

return [] unless trusted_proxies

Set.new(trusted_proxies).
map { |cidr| IPAddr.new(cidr.strip) }
Set.new(trusted_proxies)
.map { |cidr| IPAddr.new(cidr.strip) }
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

require 'spec_helper'

describe Conjur::TrustedProxyFilter do
describe Conjur::IsIpTrusted do
it "does not raise an exception when created with valid IP addresses" do
config = Conjur::ConjurConfig.new(trusted_proxies: '127.0.0.1')

expect {
Conjur::TrustedProxyFilter.new(config: config)
Conjur::IsIpTrusted.new(config: config)
}.not_to raise_error
end
end

0 comments on commit d9c17cd

Please sign in to comment.