Class: Portunus::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/portunus/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



5
6
7
8
9
10
11
# File 'lib/portunus/configuration.rb', line 5

def initialize
  @storage_adaptor = ::Portunus::StorageAdaptors::Credentials
  @encrypter = ::Portunus::Encrypters::OpenSslAes
  @keys_loaded = false
  @master_key_names = []
  @max_key_duration = 6.months
end

Instance Attribute Details

#encrypterObject

Returns the value of attribute encrypter.



3
4
5
# File 'lib/portunus/configuration.rb', line 3

def encrypter
  @encrypter
end

#max_key_durationObject

Returns the value of attribute max_key_duration.



3
4
5
# File 'lib/portunus/configuration.rb', line 3

def max_key_duration
  @max_key_duration
end

#storage_adaptorObject

Returns the value of attribute storage_adaptor.



3
4
5
# File 'lib/portunus/configuration.rb', line 3

def storage_adaptor
  @storage_adaptor
end

Instance Method Details

#add_key(key_name) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/portunus/configuration.rb', line 18

def add_key(key_name)
  @master_key_names.push(key_name)
  # we want to load all the names of the keys in the storage
  # adaptor. Because we might need to search through an environment
  # that has quite a few keys often for every key we want to load
  # the valid keys
end

#keys_loaded?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/portunus/configuration.rb', line 26

def keys_loaded?
  @keys_loaded
end

#load_keysObject



13
14
15
16
# File 'lib/portunus/configuration.rb', line 13

def load_keys
  storage_adaptor.load
  @keys_loaded = true
end

#master_key_namesObject



43
44
45
46
47
# File 'lib/portunus/configuration.rb', line 43

def master_key_names
  load_keys unless keys_loaded?

  @master_key_names
end

#reload_master_keysObject



36
37
38
39
40
41
# File 'lib/portunus/configuration.rb', line 36

def reload_master_keys
  # Perform a reload on the master keys. This is used in tests and to
  # add new keys into the environment without rebooting the app.
  @master_key_names = []
  load_keys
end

#reset_master_keysObject



30
31
32
33
34
# File 'lib/portunus/configuration.rb', line 30

def reset_master_keys
  # Clear all master keys to empty, used for testing
  @master_key_names = []
  @keys_loaded = false
end