Class: Worldline::Acquiring::SDK::Logging::Obfuscation::HeaderObfuscator
- Inherits:
-
Object
- Object
- Worldline::Acquiring::SDK::Logging::Obfuscation::HeaderObfuscator
- Defined in:
- lib/worldline/acquiring/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 |
# File 'lib/worldline/acquiring/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), } if additional_rules additional_rules.each do |name, rule| @obfuscation_rules[name.downcase] = rule end end end |
Class Method Details
.default_obfuscator ⇒ HeaderObfuscator
46 47 48 |
# File 'lib/worldline/acquiring/sdk/logging/obfuscation/header_obfuscator.rb', line 46 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.
33 34 35 36 37 |
# File 'lib/worldline/acquiring/sdk/logging/obfuscation/header_obfuscator.rb', line 33 def obfuscate_header(header_name, value) obfuscation_rule = @obfuscation_rules[header_name.downcase] return obfuscation_rule.call(value) if obfuscation_rule value end |