class Sidekiq::Encryptor::Server
Public Instance Methods
call(worker, msg, queue) { || ... }
click to toggle source
# File lib/sidekiq/encryptor.rb, line 102 def call(worker, msg, queue) return yield unless enabled? msg['args'] = validate_and_decrypt(msg['args']) yield end
Private Instance Methods
decrypt(input)
click to toggle source
# File lib/sidekiq/encryptor.rb, line 132 def decrypt(input) @adapter.decrypt(@key, input[2]) end
encrypted?(input)
click to toggle source
# File lib/sidekiq/encryptor.rb, line 124 def encrypted?(input) input.is_a?(Array) && input.size == 3 && input.first == 'Sidekiq::Encryptor' end
validate_and_decrypt(payload)
click to toggle source
# File lib/sidekiq/encryptor.rb, line 110 def validate_and_decrypt(payload) if encrypted?(payload) if version_changed?(payload) raise VersionChangeError, 'incompatible change detected' else data = decrypt(payload) or raise DecryptionError, 'key not identical or data was corrupted' Sidekiq.load_json(data) end else payload end end
version_changed?(input)
click to toggle source
# File lib/sidekiq/encryptor.rb, line 128 def version_changed?(input) input[1] != Sidekiq::Encryptor::PROTOCOL_VERSION end