Skip to content

Commit 3f15ee4

Browse files
committed
Merge 9.2.0 release into master
2 parents 2bb8d00 + 7bf9a94 commit 3f15ee4

14 files changed

Lines changed: 24 additions & 170 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changelog
22

3+
## 9.2.0
4+
5+
**Changes:**
6+
7+
- Slim down the default request context to `headers`, `ip` and `library`; the remaining data is already available via `headers`.
8+
- Remove the internal `Castle::ClientId::Extract` service and the now-unused `cookies` plumbing in `Castle::Context::GetDefault`.
9+
- No longer read the API secret from the `CASTLE_API_SECRET` environment variable automatically; set `Castle.api_secret` explicitly (for example `Castle.api_secret = ENV.fetch('CASTLE_API_SECRET')`).
10+
311
## 9.1.0
412

513
**Enhancements:**

‎Gemfile.lock‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
castle-rb (9.1.0)
4+
castle-rb (9.2.0)
55
base64 (~> 0.2)
66

77
GEM

‎lib/castle.rb‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@
7878
castle/headers/format
7979
castle/headers/extract
8080
castle/secure_mode
81-
castle/client_id/extract
8281
castle/ips/extract
8382
castle/core/get_connection
8483
castle/core/process_response

‎lib/castle/client_id/extract.rb‎

Lines changed: 0 additions & 21 deletions
This file was deleted.

‎lib/castle/configuration.rb‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def reset
6969
self.base_url = BASE_URL
7070
self.allowlisted = [].freeze
7171
self.denylisted = [].freeze
72-
self.api_secret = ENV.fetch('CASTLE_API_SECRET', '')
72+
self.api_secret = ''
7373
self.ip_headers = [].freeze
7474
self.trusted_proxies = [].freeze
7575
self.trust_proxy_chain = false

‎lib/castle/context/get_default.rb‎

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,50 +3,21 @@
33
module Castle
44
module Context
55
class GetDefault
6-
def initialize(request, cookies = nil)
6+
def initialize(request)
77
@pre_headers = Castle::Headers::Filter.new(request).call
8-
@cookies = cookies || request.cookies
9-
@request = request
108
end
119

1210
def call
13-
{
14-
client_id: client_id,
15-
active: true,
16-
headers: headers,
17-
ip: ip,
18-
library: {
19-
name: 'castle-rb',
20-
version: Castle::VERSION
21-
}
22-
}.tap do |result|
23-
result[:locale] = locale if locale
24-
result[:user_agent] = user_agent if user_agent
25-
end
11+
{ headers: headers, ip: ip, library: { name: 'castle-rb', version: Castle::VERSION } }
2612
end
2713

2814
private
2915

30-
# @return [String]
31-
def locale
32-
@pre_headers['Accept-Language']
33-
end
34-
35-
# @return [String]
36-
def user_agent
37-
@pre_headers['User-Agent']
38-
end
39-
4016
# @return [String]
4117
def ip
4218
Castle::IPs::Extract.new(@pre_headers).call
4319
end
4420

45-
# @return [String]
46-
def client_id
47-
Castle::ClientId::Extract.new(@pre_headers, @cookies).call
48-
end
49-
5021
# formatted and filtered headers
5122
# @return [Hash]
5223
def headers

‎lib/castle/context/prepare.rb‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class << self
99
# @param options [Hash]
1010
# @return [Hash]
1111
def call(request, options = {})
12-
default_context = Castle::Context::GetDefault.new(request, options[:cookies]).call
12+
default_context = Castle::Context::GetDefault.new(request).call
1313
Castle::Context::Merge.call(default_context, options[:context])
1414
end
1515
end

‎lib/castle/version.rb‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

33
module Castle
4-
VERSION = '9.1.0'
4+
VERSION = '9.2.0'
55
end

‎spec/lib/castle/client_id/extract_spec.rb‎

Lines changed: 0 additions & 47 deletions
This file was deleted.

‎spec/lib/castle/client_spec.rb‎

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,7 @@
2020
let(:client_with_no_timestamp) { described_class.new(context: request_to_context) }
2121

2222
let(:headers) { { 'Content-Length': '0', 'User-Agent': ua, 'X-Forwarded-For': ip.to_s, Cookie: true } }
23-
let(:context) do
24-
{
25-
client_id: 'abcd',
26-
active: true,
27-
user_agent: ua,
28-
headers: headers,
29-
ip: ip,
30-
library: {
31-
name: 'castle-rb',
32-
version: '2.2.0'
33-
}
34-
}
35-
end
23+
let(:context) { { headers: headers, ip: ip, library: { name: 'castle-rb', version: '2.2.0' } } }
3624

3725
let(:time_now) { Time.now }
3826
let(:time_auto) { time_now.utc.iso8601(3) }

0 commit comments

Comments
 (0)