Module: ResponseEncryption

Defined in:
lib/response_encryption.rb,
lib/response_encryption/railtie.rb,
lib/response_encryption/version.rb,
lib/response_encryption/symmetric_encrypter.rb,
lib/response_encryption/asymmetric_encrypter.rb,
lib/response_encryption/act_as_a_encryption_controller.rb

Defined Under Namespace

Modules: ActsAsEncryptionController, EncryptAttributes Classes: ActiveModelService, AsymmetricEncrypter, Railtie, SymmetricEncrypter

Constant Summary collapse

WRITER_METHODS =
[]
ACCESSOR_METHODS =
[:serializer_gem, :algothim, :algorithm_key_length, :block_cipher_mode, :enabled, :cipher, :encryption_strategy]
VERSION =
"0.1.0"

Class Method Summary collapse

Class Method Details

.active_model_serializers?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/response_encryption.rb', line 48

def active_model_serializers?
  self.serializer_gem == :active_model_serializers
end

.available_encryption_strategiesObject



36
37
38
# File 'lib/response_encryption.rb', line 36

def available_encryption_strategies
  i(encrypted_attributes encrypted_body)
end

.available_serializer_gemsObject



32
33
34
# File 'lib/response_encryption.rb', line 32

def available_serializer_gems
  i(active_model_serializers jsonapi_resources none)
end

.cipherObject



28
29
30
# File 'lib/response_encryption.rb', line 28

def cipher
  @cipher = OpenSSL::Cipher.new("#{ algothim }-#{ algorithm_key_length }-#{ block_cipher_mode }")
end

.configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



22
23
24
25
26
# File 'lib/response_encryption.rb', line 22

def configure
  yield self if block_given?
  raise "The serializer_gem value is invalid. Please select one of these: #{ available_serializer_gems.join(', ') }" unless available_serializer_gems.include? serializer_gem
  raise "The available_encryption_strategies value is invalid. Please select one of these: #{ available_serializer_gems.join(', ') }" unless available_encryption_strategies.include? encryption_strategy
end

.encrypted_attributes_strategy?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/response_encryption.rb', line 40

def encrypted_attributes_strategy?
  self.encryption_strategy == :encrypted_attributes
end

.encrypted_body_strategy?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/response_encryption.rb', line 44

def encrypted_body_strategy?
  self.encryption_strategy == :encrypted_body
end

.jsonapi_resources?Boolean

Returns:

  • (Boolean)


52
53
54
# File 'lib/response_encryption.rb', line 52

def jsonapi_resources?
  self.serializer_gem == :jsonapi_resources
end