module Sidekiq::Crypt
Constants
- VERSION
Public Class Methods
configuration(options = {})
click to toggle source
# File lib/sidekiq-crypt.rb, line 13 def configuration(options = {}) @configuration ||= Configuration.new(options) end
configure(options = {}) { |configuration(options)| ... }
click to toggle source
# File lib/sidekiq-crypt.rb, line 17 def configure(options = {}) block_given? ? yield(configuration(options)) : configuration(options) configuration.filters.flatten! validate_configuration! inject_sidekiq_middlewares end
inject_sidekiq_middlewares()
click to toggle source
# File lib/sidekiq-crypt.rb, line 26 def inject_sidekiq_middlewares inject_client_middleware inject_server_middleware end
Private Class Methods
current_raw_key()
click to toggle source
# File lib/sidekiq-crypt.rb, line 60 def current_raw_key # returns the base64 encoded version of the key configuration.key_store[configuration.current_key_version] end
inject_client_middleware()
click to toggle source
# File lib/sidekiq-crypt.rb, line 33 def inject_client_middleware ::Sidekiq.configure_client do |config| config.client_middleware do |chain| chain.add Sidekiq::Crypt::ClientMiddleware, configuration: configuration end end end
inject_server_middleware()
click to toggle source
# File lib/sidekiq-crypt.rb, line 41 def inject_server_middleware ::Sidekiq.configure_server do |config| config.client_middleware do |chain| chain.add Sidekiq::Crypt::ClientMiddleware, configuration: configuration end config.server_middleware do |chain| chain.add Sidekiq::Crypt::ServerMiddleware end end end
invalid_key?()
click to toggle source
# File lib/sidekiq-crypt.rb, line 65 def invalid_key? Sidekiq::Crypt::Cipher.encrypt('dummy_str', Sidekiq::Crypt::Cipher.random_iv) false rescue StandardError true end
validate_configuration!()
click to toggle source
# File lib/sidekiq-crypt.rb, line 53 def validate_configuration! raise 'you must specify current key version' if configuration.current_key_version.blank? raise 'you must specify a hash for key store' if configuration.key_store.blank? raise "current_key_version can't be found in key_store" if current_raw_key.nil? raise 'current key is not valid for encryption' if invalid_key? end