castle-rb 3.3.0 → 3.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ef681fe4eea20aa8dacb69718809e49103e17060a5f2b0a57331982c9d36b59f
4
- data.tar.gz: 6ab1e89bdefc563ce78ca7ae9666fb86f2b22ce0b740250a10f67fa3eaa1a98b
3
+ metadata.gz: 5d0999873fc06348f78e4663a5bf653fe64f62f8432af21a7596dca3ed935ee3
4
+ data.tar.gz: a3e523ef2862b8f2928c180d70242aac5afda8594f5d48f0fc2647186a107fb5
5
5
  SHA512:
6
- metadata.gz: cbd67d2101f93caa9c3c793171759bdf0401313ff6c3dbccacc0843674a6ec36d8b0c63e1c705a54e7f27d0b10b59990b85131ad6f492f02ba1e8b2673679583
7
- data.tar.gz: c56cbdb356049465687277a388d39c62fe41a90e8b02436c38568fd7d8e18e7f8fcd12ad37e5f87c6b6b2a0fce0651da1a2863d3f14034b90da41cc5a876cf6e
6
+ metadata.gz: 876a90d7bf0ceebefbd0ee2243f533cd520a91b8415fbbcb9b85eb2df5aa58dcc52717d267bb9edf89debd5a9e7f94f793b3564b34aaf6502a81885025ad6c08
7
+ data.tar.gz: 97f910519f2e67c9737219e4f7fe5c91f08bb817942bccc14dc534d67ec0a71db0d408d75454e4c67d148ca9aa60c30f3f9252a279321783d79ea07fd5cc43f6
@@ -16,7 +16,9 @@ module Castle
16
16
  'Forwarded',
17
17
  'X-Forwarded',
18
18
  'X-Real-IP',
19
- 'REMOTE_ADDR'
19
+ 'REMOTE_ADDR',
20
+ 'X-Forwarded-For',
21
+ 'CF_CONNECTING_IP'
20
22
  ].freeze
21
23
 
22
24
  BLACKLISTED = ['HTTP_COOKIE'].freeze
@@ -9,6 +9,8 @@ module Castle
9
9
  end
10
10
 
11
11
  def call
12
+ return @request.env['HTTP_CF_CONNECTING_IP'] if @request.env['HTTP_CF_CONNECTING_IP']
13
+ return @request.remote_ip if @request.respond_to?(:remote_ip)
12
14
  @request.ip
13
15
  end
14
16
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Castle
4
- VERSION = '3.3.0'
4
+ VERSION = '3.3.1'
5
5
  end
@@ -77,7 +77,7 @@ describe Castle::Configuration do
77
77
 
78
78
  describe 'whitelisted' do
79
79
  it do
80
- expect(config.whitelisted.size).to be_eql(11)
80
+ expect(config.whitelisted.size).to be_eql(13)
81
81
  end
82
82
 
83
83
  context 'setter' do
@@ -94,7 +94,7 @@ describe Castle::Configuration do
94
94
  config.whitelisted += ['header']
95
95
  end
96
96
  it { expect(config.whitelisted).to be_include('Header') }
97
- it { expect(config.whitelisted.size).to be_eql(12) }
97
+ it { expect(config.whitelisted.size).to be_eql(14) }
98
98
  end
99
99
  end
100
100
 
@@ -6,8 +6,22 @@ describe Castle::Extractors::IP do
6
6
  let(:request) { Rack::Request.new(env) }
7
7
 
8
8
  describe 'ip' do
9
- let(:env) { Rack::MockRequest.env_for( '/', 'HTTP_X_FORWARDED_FOR' => '1.2.3.4') }
9
+ context 'when regular ip' do
10
+ let(:env) { Rack::MockRequest.env_for('/', 'HTTP_X_FORWARDED_FOR' => '1.2.3.5') }
10
11
 
11
- it { expect(extractor.call).to eql('1.2.3.4') }
12
+ it { expect(extractor.call).to eql('1.2.3.5') }
13
+ end
14
+
15
+ context 'when cf remote_ip' do
16
+ let(:env) do
17
+ Rack::MockRequest.env_for(
18
+ '/',
19
+ 'HTTP_CF_CONNECTING_IP' => '1.2.3.4',
20
+ 'HTTP_X_FORWARDED_FOR' => '1.2.3.5'
21
+ )
22
+ end
23
+
24
+ it { expect(extractor.call).to eql('1.2.3.4') }
25
+ end
12
26
  end
13
27
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: castle-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.0
4
+ version: 3.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Johan Brissmyr
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-12 00:00:00.000000000 Z
11
+ date: 2018-01-22 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Castle protects your users from account compromise
14
14
  email: johan@castle.io