Class: ActiveCipherStorage::Configuration
- Inherits:
-
Object
- Object
- ActiveCipherStorage::Configuration
- Defined in:
- lib/active_cipher_storage/configuration.rb
Constant Summary collapse
- ALGORITHMS =
Supported algorithm identifiers.
%w[aes-256-gcm].freeze
- MINIMUM_S3_MULTIPART_PART_SIZE =
Bytes per plaintext chunk in streaming mode (default 5 MiB — matches the minimum S3 multipart part size, so each chunk maps to exactly one part).
5 * 1024 * 1024
- DEFAULT_CHUNK_SIZE =
5 * 1024 * 1024
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
- #algorithm ⇒ Object
- #algorithm=(value) ⇒ Object
- #chunk_size ⇒ Object
- #chunk_size=(value) ⇒ Object
- #encrypt_uploads ⇒ Object
- #encrypt_uploads=(value) ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #logger ⇒ Object
- #logger=(value) ⇒ Object
- #provider ⇒ Object
-
#provider=(value) ⇒ Object
Accept a provider instance or a symbol shorthand (:env, :aws_kms).
- #validate! ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
16 17 18 19 20 21 22 |
# File 'lib/active_cipher_storage/configuration.rb', line 16 def initialize @config = ActiveSupport::OrderedOptions.new self.algorithm = "aes-256-gcm" self.chunk_size = DEFAULT_CHUNK_SIZE self.encrypt_uploads = true self.logger = Logger.new($stdout, level: Logger::WARN) end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
14 15 16 |
# File 'lib/active_cipher_storage/configuration.rb', line 14 def config @config end |
Instance Method Details
#algorithm ⇒ Object
24 25 26 |
# File 'lib/active_cipher_storage/configuration.rb', line 24 def algorithm config.algorithm end |
#algorithm=(value) ⇒ Object
28 29 30 |
# File 'lib/active_cipher_storage/configuration.rb', line 28 def algorithm=(value) config.algorithm = value end |
#chunk_size ⇒ Object
32 33 34 |
# File 'lib/active_cipher_storage/configuration.rb', line 32 def chunk_size config.chunk_size end |
#chunk_size=(value) ⇒ Object
36 37 38 |
# File 'lib/active_cipher_storage/configuration.rb', line 36 def chunk_size=(value) config.chunk_size = value end |
#encrypt_uploads ⇒ Object
40 41 42 |
# File 'lib/active_cipher_storage/configuration.rb', line 40 def encrypt_uploads config.encrypt_uploads end |
#encrypt_uploads=(value) ⇒ Object
44 45 46 |
# File 'lib/active_cipher_storage/configuration.rb', line 44 def encrypt_uploads=(value) config.encrypt_uploads = value end |
#logger ⇒ Object
48 49 50 |
# File 'lib/active_cipher_storage/configuration.rb', line 48 def logger config.logger end |
#logger=(value) ⇒ Object
52 53 54 |
# File 'lib/active_cipher_storage/configuration.rb', line 52 def logger=(value) config.logger = value end |
#provider ⇒ Object
56 57 58 |
# File 'lib/active_cipher_storage/configuration.rb', line 56 def provider config.provider end |
#provider=(value) ⇒ Object
Accept a provider instance or a symbol shorthand (:env, :aws_kms).
61 62 63 64 65 66 67 68 69 70 |
# File 'lib/active_cipher_storage/configuration.rb', line 61 def provider=(value) config.provider = case value when Symbol then resolve_provider(value) when Providers::Base then value else raise ArgumentError, "provider must be a Providers::Base instance or " \ "one of :env, :aws_kms — got #{value.inspect}" end end |
#validate! ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/active_cipher_storage/configuration.rb', line 72 def validate! raise ProviderError, "No KMS provider configured. " \ "Set ActiveCipherStorage.configuration.provider." unless provider unless ALGORITHMS.include?(algorithm) raise ArgumentError, "Unsupported algorithm: #{algorithm.inspect}. " \ "Supported: #{ALGORITHMS.join(', ')}" end raise ArgumentError, "chunk_size must be positive" unless chunk_size.positive? return if [true, false].include?(encrypt_uploads) raise ArgumentError, "encrypt_uploads must be true or false" end |