Class: Karafka::Pro::Encryption::Messages::Parser
- Inherits:
-
Messages::Parser
- Object
- Messages::Parser
- Karafka::Pro::Encryption::Messages::Parser
- Defined in:
- lib/karafka/pro/encryption/messages/parser.rb
Overview
Note:
There may be a case where someone decides not to encrypt data and we start getting unencrypted payloads. That is why we always rely on message headers for encryption indication.
Pro parser that takes into consideration encryption usage
Instance Method Summary collapse
-
#call(message) ⇒ Object
Deserialized payload.
Instance Method Details
#call(message) ⇒ Object
Returns deserialized payload.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/karafka/pro/encryption/messages/parser.rb', line 31 def call() headers = .headers encryption = headers['encryption'] fingerprint = headers['encryption_fingerprint'] return super() unless active && encryption # Decrypt raw payload so it can be handled by the default parser logic decrypted_payload = cipher.decrypt( encryption, .raw_payload ) .raw_payload = decrypted_payload return super() unless fingerprint && fingerprinter = fingerprinter.hexdigest(decrypted_payload) return super() if == fingerprint raise(Errors::FingerprintVerificationError, .to_s) end |