Class: Worldline::Connect::SDK::Logging::Obfuscation::HeaderObfuscator
- Inherits:
-
Object
- Object
- Worldline::Connect::SDK::Logging::Obfuscation::HeaderObfuscator
- Defined in:
- lib/worldline/connect/sdk/logging/obfuscation/header_obfuscator.rb
Overview
A class that can be used to obfuscate headers.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(additional_rules = nil) ⇒ HeaderObfuscator
constructor
Creates a new header obfuscator.
-
#obfuscate_header(header_name, value) ⇒ String
Obfuscates the value for the given header as necessary.
Constructor Details
#initialize(additional_rules = nil) ⇒ HeaderObfuscator
Creates a new header obfuscator. This will contain some pre-defined obfuscation rules, as well as any provided custom rules
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/worldline/connect/sdk/logging/obfuscation/header_obfuscator.rb', line 16 def initialize(additional_rules = nil) @obfuscation_rules = { "authorization" => Obfuscation.obfuscate_with_fixed_length(8), "www-authenticate" => Obfuscation.obfuscate_with_fixed_length(8), "proxy-authenticate" => Obfuscation.obfuscate_with_fixed_length(8), "proxy-authorization" => Obfuscation.obfuscate_with_fixed_length(8), "x-gcs-authentication-token" => Obfuscation.obfuscate_with_fixed_length(8), "x-gcs-callerpassword" => Obfuscation.obfuscate_with_fixed_length(8), } if additional_rules additional_rules.each do |name, rule| @obfuscation_rules[name.downcase] = rule end end end |
Class Method Details
.default_obfuscator ⇒ HeaderObfuscator
48 49 50 |
# File 'lib/worldline/connect/sdk/logging/obfuscation/header_obfuscator.rb', line 48 def self.default_obfuscator DEFAULT_OBFUSCATOR end |
Instance Method Details
#obfuscate_header(header_name, value) ⇒ String
Obfuscates the value for the given header as necessary.
35 36 37 38 39 |
# File 'lib/worldline/connect/sdk/logging/obfuscation/header_obfuscator.rb', line 35 def obfuscate_header(header_name, value) obfuscation_rule = @obfuscation_rules[header_name.downcase] return obfuscation_rule.call(value) if obfuscation_rule value end |