Class: ActiveRecord::Encryption::Context
Relationships & Source Files | |
Inherits: | Object |
Defined in: | activerecord/lib/active_record/encryption/context.rb |
Overview
An encryption context configures the different entities used to perform encryption:
-
A key provider
-
A key generator
-
An encryptor, the facade to encrypt data
-
A cipher, the encryption algorithm
-
A message serializer
Constant Summary
-
PROPERTIES =
# File 'activerecord/lib/active_record/encryption/context.rb', line 13%i[ key_provider key_generator cipher message_serializer encryptor frozen_encryption ]
Class Method Summary
- .new ⇒ Context constructor
Instance Method Summary
- #frozen_encryption?
- #key_provider
- #build_default_key_provider private
- #set_defaults private
Constructor Details
.new ⇒ Context
# File 'activerecord/lib/active_record/encryption/context.rb', line 17
def initialize set_defaults end
Instance Method Details
#build_default_key_provider (private)
[ GitHub ]# File 'activerecord/lib/active_record/encryption/context.rb', line 37
def build_default_key_provider ActiveRecord::Encryption::DerivedSecretKeyProvider.new(ActiveRecord::Encryption.config.primary_key) end
#frozen_encryption?
[ GitHub ]# File 'activerecord/lib/active_record/encryption/context.rb', line 21
alias frozen_encryption? frozen_encryption
#key_provider
[ GitHub ]# File 'activerecord/lib/active_record/encryption/context.rb', line 24
def key_provider @key_provider ||= build_default_key_provider end
#set_defaults (private)
[ GitHub ]# File 'activerecord/lib/active_record/encryption/context.rb', line 29
def set_defaults self.frozen_encryption = false self.key_generator = ActiveRecord::Encryption::KeyGenerator.new self.cipher = ActiveRecord::Encryption::Cipher.new self.encryptor = ActiveRecord::Encryption::Encryptor.new self. = ActiveRecord::Encryption::MessageSerializer.new end