strongmind-platform-sdk 3.34.1 → 3.34.2
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 +4 -4
- data/lib/platform_sdk/identity/error_handleable.rb +14 -25
- data/lib/platform_sdk/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: '028ca313c6f9bce49fb5b02e6f929b2ed0939f191938d450d5433647e6ef644b'
|
|
4
|
+
data.tar.gz: 71e0174a2f1929f7acad9727f71c4286ba9791b5f02a0a011a23485de2d22886
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fc53e003fdc583a4afc1c0ea2cd8e4253a23f44f38d08849b2d56c2a57d625e876cadb668df2bbbbdc705ef2d0b57362462baf27336f9fa05e337841b321aebc
|
|
7
|
+
data.tar.gz: b4a08cd44666bbc7c467afc211f92084b55942609231d121b04e3bee5078a6577be028b0556e8352d080f1695be0055e582250f59775db58a73d607a92c18e9a
|
|
@@ -4,12 +4,7 @@ module PlatformSdk
|
|
|
4
4
|
module Identity
|
|
5
5
|
# Error handling for Identity SDK
|
|
6
6
|
module ErrorHandleable
|
|
7
|
-
|
|
8
|
-
# carries client credentials; redact those fields (form-encoded and
|
|
9
|
-
# JSON shapes) so an auth outage can't write secrets to consumer logs.
|
|
10
|
-
SENSITIVE_KEYS = 'client_secret|client_assertion|refresh_token|password'
|
|
11
|
-
FORM_SECRET_PATTERN = /(#{SENSITIVE_KEYS})=[^&]*/i
|
|
12
|
-
JSON_SECRET_PATTERN = /("(?:#{SENSITIVE_KEYS})"\s*:\s*")[^"]*(")/i
|
|
7
|
+
REDACTED = '[REDACTED]'
|
|
13
8
|
|
|
14
9
|
def with_rescue
|
|
15
10
|
yield
|
|
@@ -22,12 +17,9 @@ module PlatformSdk
|
|
|
22
17
|
end
|
|
23
18
|
|
|
24
19
|
def raise_error_with_payload(exception_class, error)
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
# request body/headers - which can hold a client_secret or bearer
|
|
29
|
-
# token - must be scrubbed here too, not just in the log line above.
|
|
30
|
-
raise exception_class, scrub_response(error.response)
|
|
20
|
+
payload = error_log_payload(exception_class, error)
|
|
21
|
+
Rails.logger.info(payload.to_json) if defined?(Rails)
|
|
22
|
+
raise exception_class.new(error_message(payload), scrub_response(error.response)), cause: nil
|
|
31
23
|
end
|
|
32
24
|
|
|
33
25
|
# No ActiveSupport here (String#demodulize): this must work for
|
|
@@ -36,25 +28,20 @@ module PlatformSdk
|
|
|
36
28
|
def error_log_payload(exception_class, error)
|
|
37
29
|
{
|
|
38
30
|
exception: exception_class.name.split('::').last,
|
|
39
|
-
|
|
31
|
+
method: error.response.dig(:request, :method),
|
|
32
|
+
path: error.response.dig(:request, :url_path),
|
|
40
33
|
response_body: error.response[:body],
|
|
41
34
|
status: error.response[:status]
|
|
42
35
|
}.compact
|
|
43
36
|
end
|
|
44
37
|
|
|
45
|
-
def
|
|
46
|
-
|
|
38
|
+
def error_message(payload)
|
|
39
|
+
message = "the server responded with status #{payload[:status]}"
|
|
40
|
+
return message unless payload[:method] && payload[:path]
|
|
47
41
|
|
|
48
|
-
|
|
49
|
-
.gsub(JSON_SECRET_PATTERN, '\1[REDACTED]\2')
|
|
42
|
+
"#{message} for #{payload[:method].to_s.upcase} #{payload[:path]}"
|
|
50
43
|
end
|
|
51
44
|
|
|
52
|
-
# Returns a scrubbed copy of the Faraday error response hash; the
|
|
53
|
-
# original (and its nested :request hash) are left untouched. Only
|
|
54
|
-
# [:request][:body] and [:request][:headers] are touched -
|
|
55
|
-
# [:status] and [:body] (the response body) are read elsewhere
|
|
56
|
-
# (e.g. e.response&.dig(:status), e.response&.dig(:body, 'paramName'))
|
|
57
|
-
# and must reach consumers unchanged.
|
|
58
45
|
def scrub_response(response)
|
|
59
46
|
return response unless response.is_a?(Hash)
|
|
60
47
|
|
|
@@ -65,7 +52,9 @@ module PlatformSdk
|
|
|
65
52
|
|
|
66
53
|
def scrub_request(request)
|
|
67
54
|
scrubbed_request = request.dup
|
|
68
|
-
scrubbed_request[:body] =
|
|
55
|
+
scrubbed_request[:body] = REDACTED if request.key?(:body)
|
|
56
|
+
scrubbed_request[:params] = REDACTED if request.key?(:params)
|
|
57
|
+
scrubbed_request[:url] = request[:url_path] if request.key?(:url)
|
|
69
58
|
scrubbed_request[:headers] = scrub_headers(request[:headers]) if request[:headers].is_a?(Hash)
|
|
70
59
|
scrubbed_request
|
|
71
60
|
end
|
|
@@ -75,7 +64,7 @@ module PlatformSdk
|
|
|
75
64
|
def scrub_headers(headers)
|
|
76
65
|
scrubbed = headers.dup
|
|
77
66
|
scrubbed.each_key do |key|
|
|
78
|
-
scrubbed[key] =
|
|
67
|
+
scrubbed[key] = REDACTED if key.to_s.casecmp('authorization').zero?
|
|
79
68
|
end
|
|
80
69
|
scrubbed
|
|
81
70
|
end
|
data/lib/platform_sdk/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: strongmind-platform-sdk
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.34.
|
|
4
|
+
version: 3.34.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Platform Team
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-10-
|
|
11
|
+
date: 2026-10-22 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: base64
|
|
@@ -392,7 +392,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
392
392
|
- !ruby/object:Gem::Version
|
|
393
393
|
version: '0'
|
|
394
394
|
requirements: []
|
|
395
|
-
rubygems_version: 3.4.
|
|
395
|
+
rubygems_version: 3.4.19
|
|
396
396
|
signing_key:
|
|
397
397
|
specification_version: 4
|
|
398
398
|
summary: This gem is intended to provide clients and models for accessing the Platform
|