17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/chamber/encryption_methods/public_key.rb', line 17
def self.decrypt(_settings_key, value, decryption_key)
return value if decryption_key.nil?
decoded_string = ::Base64.strict_decode64(value)
unencrypted_value = decryption_key.private_decrypt(decoded_string)
::YAML.safe_load(unencrypted_value,
aliases: true,
permitted_classes: [
::Date,
::Time,
::Regexp,
])
rescue ::Psych::DisallowedClass => error
raise ::Chamber::Errors::DisallowedClass, <<~HEREDOC
#{error.message}
You attempted to load a class instance via your Chamber settings that is not allowed.
See https://github.com/thekompanee/chamber/wiki/Upgrading-To-Chamber-3.0#limiting-complex-classes for full details.
HEREDOC
rescue ::TypeError
unencrypted_value
end
|