Class: ActiveRecord::Encryption::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/active_record/encryption/config.rb

Overview

Container of configuration options

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



13
14
15
# File 'lib/active_record/encryption/config.rb', line 13

def initialize
  set_defaults
end

Instance Attribute Details

#add_to_filter_parametersObject

Returns the value of attribute add_to_filter_parameters.



9
10
11
# File 'lib/active_record/encryption/config.rb', line 9

def add_to_filter_parameters
  @add_to_filter_parameters
end

#deterministic_keyObject

Returns the value of attribute deterministic_key.



9
10
11
# File 'lib/active_record/encryption/config.rb', line 9

def deterministic_key
  @deterministic_key
end

#encrypt_fixturesObject

Returns the value of attribute encrypt_fixtures.



9
10
11
# File 'lib/active_record/encryption/config.rb', line 9

def encrypt_fixtures
  @encrypt_fixtures
end

#excluded_from_filter_parametersObject

Returns the value of attribute excluded_from_filter_parameters.



9
10
11
# File 'lib/active_record/encryption/config.rb', line 9

def excluded_from_filter_parameters
  @excluded_from_filter_parameters
end

#extend_queriesObject

Returns the value of attribute extend_queries.



9
10
11
# File 'lib/active_record/encryption/config.rb', line 9

def extend_queries
  @extend_queries
end

#forced_encoding_for_deterministic_encryptionObject

Returns the value of attribute forced_encoding_for_deterministic_encryption.



9
10
11
# File 'lib/active_record/encryption/config.rb', line 9

def forced_encoding_for_deterministic_encryption
  @forced_encoding_for_deterministic_encryption
end

#hash_digest_classObject

Returns the value of attribute hash_digest_class.



9
10
11
# File 'lib/active_record/encryption/config.rb', line 9

def hash_digest_class
  @hash_digest_class
end

#key_derivation_saltObject

Returns the value of attribute key_derivation_salt.



9
10
11
# File 'lib/active_record/encryption/config.rb', line 9

def key_derivation_salt
  @key_derivation_salt
end

#previous_schemesObject

Returns the value of attribute previous_schemes.



9
10
11
# File 'lib/active_record/encryption/config.rb', line 9

def previous_schemes
  @previous_schemes
end

#primary_keyObject

Returns the value of attribute primary_key.



9
10
11
# File 'lib/active_record/encryption/config.rb', line 9

def primary_key
  @primary_key
end

#store_key_referencesObject

Returns the value of attribute store_key_references.



9
10
11
# File 'lib/active_record/encryption/config.rb', line 9

def store_key_references
  @store_key_references
end

#support_unencrypted_dataObject

Returns the value of attribute support_unencrypted_data.



9
10
11
# File 'lib/active_record/encryption/config.rb', line 9

def support_unencrypted_data
  @support_unencrypted_data
end

#validate_column_sizeObject

Returns the value of attribute validate_column_size.



9
10
11
# File 'lib/active_record/encryption/config.rb', line 9

def validate_column_size
  @validate_column_size
end

Instance Method Details

#previous=(previous_schemes_properties) ⇒ Object

Configure previous encryption schemes.

config.active_record.encryption.previous = [ { key_provider: MyOldKeyProvider.new } ]


20
21
22
23
24
# File 'lib/active_record/encryption/config.rb', line 20

def previous=(previous_schemes_properties)
  previous_schemes_properties.each do |properties|
    add_previous_scheme(**properties)
  end
end

#support_sha1_for_non_deterministic_encryption=(value) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/active_record/encryption/config.rb', line 26

def support_sha1_for_non_deterministic_encryption=(value)
  if value && has_primary_key?
    sha1_key_generator = ActiveRecord::Encryption::KeyGenerator.new(hash_digest_class: OpenSSL::Digest::SHA1)
    sha1_key_provider = ActiveRecord::Encryption::DerivedSecretKeyProvider.new(primary_key, key_generator: sha1_key_generator)
    add_previous_scheme key_provider: sha1_key_provider
  end
end