Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename the TrustedProxyFilter class to IsIpTrusted #2484

Merged
merged 1 commit into from
Feb 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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