Class: Karafka::Pro::Encryption::Messages::Middleware
- Inherits:
-
Object
- Object
- Karafka::Pro::Encryption::Messages::Middleware
- Defined in:
- lib/karafka/pro/encryption/messages/middleware.rb
Overview
Middleware for WaterDrop. It automatically encrypts messages payload. It is injected only if encryption is enabled. It also fingerprints the payload for verification if fingerprinting was enabled
Instance Method Summary collapse
-
#call(message) ⇒ Hash
Hash with encrypted payload and encryption version indicator.
Instance Method Details
#call(message) ⇒ Hash
Returns hash with encrypted payload and encryption version indicator.
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/karafka/pro/encryption/messages/middleware.rb', line 31 def call() payload = [:payload] [:headers] ||= {} [:headers]['encryption'] = version [:payload] = cipher.encrypt(payload) return unless fingerprinter [:headers]['encryption_fingerprint'] = fingerprinter.hexdigest(payload) end |