Class: HatiConfig::Encryption::EnvKeyProvider

Inherits:
KeyProvider
  • Object
show all
Defined in:
lib/hati_config/encryption.rb

Overview

EnvKeyProvider gets the encryption key from an environment variable.

Instance Method Summary collapse

Methods inherited from KeyProvider

create

Constructor Details

#initialize(options = {}) ⇒ EnvKeyProvider

Returns a new instance of EnvKeyProvider.



189
190
191
192
# File 'lib/hati_config/encryption.rb', line 189

def initialize(options = {})
  super()
  @env_var = options[:env_var] || 'HATI_CONFIG_ENCRYPTION_KEY'
end

Instance Method Details

#key ⇒ Object

Raises:



194
195
196
197
198
199
# File 'lib/hati_config/encryption.rb', line 194

def key
  key = ENV.fetch(@env_var, nil)
  raise EncryptionError, "Encryption key not found in environment variable #{@env_var}" unless key

  key
end