Module: Vault::Rails::Configurable

Includes:
Configurable
Defined in:
lib/vault/rails/configurable.rb

Instance Method Summary collapse

Instance Method Details

#applicationString

The name of the Vault::Rails application.

Returns:

  • (String)

Raises:

  • (RuntimeError)

    if the application has not been set



12
13
14
15
16
17
18
19
20
# File 'lib/vault/rails/configurable.rb', line 12

def application
  if defined?(@application) && !@application.nil?
    return @application
  end
  if ENV.has_key?("VAULT_RAILS_APPLICATION")
    return ENV["VAULT_RAILS_APPLICATION"]
  end
  raise RuntimeError, "Must set `Vault::Rails#application'!"
end

#application=(val) ⇒ Object

Set the name of the application.

Parameters:

  • val (String)


25
26
27
# File 'lib/vault/rails/configurable.rb', line 25

def application=(val)
  @application = val
end

#default_role_nameString

Gets the default role name.

Returns:

  • (String)


132
133
134
# File 'lib/vault/rails/configurable.rb', line 132

def default_role_name
  @default_role_name
end

#default_role_name=(val) ⇒ Object

Sets the default role to use with various plugins.

Parameters:

  • val (String)


139
140
141
# File 'lib/vault/rails/configurable.rb', line 139

def default_role_name=(val)
  @default_role_name = val
end

#enabled=(val) ⇒ true, false

Sets whether Vault is enabled. Users can set this in an initializer depending on their Rails environment.

Examples:

Vault.configure do |vault|
  vault.enabled = Rails.env.production?
end

Returns:

  • (true, false)


54
55
56
# File 'lib/vault/rails/configurable.rb', line 54

def enabled=(val)
  @enabled = !!val
end

#enabled?true, false

Whether the connection to Vault is enabled. The default value is ‘false`, which means vault-rails will perform in-memory encryption/decryption and not attempt to talk to a real Vault server. This is useful for development and testing.

Returns:

  • (true, false)


35
36
37
38
39
40
41
42
43
# File 'lib/vault/rails/configurable.rb', line 35

def enabled?
  if defined?(@enabled) && !@enabled.nil?
    return @enabled
  end
  if ENV.has_key?("VAULT_RAILS_ENABLED")
    return (ENV["VAULT_RAILS_ENABLED"] == "true")
  end
  return false
end

#in_memory_warnings_enabled=(val) ⇒ true, false

Sets whether warnings about in-memory ciphers are enabled. Users can set this in an initializer depending on their Rails environment.

Examples:

Vault.configure do |vault|
  vault.in_memory_warnings_enabled = !Rails.env.test?
end

Returns:

  • (true, false)


80
81
82
# File 'lib/vault/rails/configurable.rb', line 80

def in_memory_warnings_enabled=(val)
  @in_memory_warnings_enabled = val
end

#in_memory_warnings_enabled?true, false

Whether warnings about in-memory ciphers are enabled. The default value is ‘true`, which means vault-rails will log a warning for every attempt to encrypt or decrypt using an in-memory cipher. This is useful for development and testing.

Returns:

  • (true, false)


64
65
66
67
68
69
# File 'lib/vault/rails/configurable.rb', line 64

def in_memory_warnings_enabled?
  if !defined?(@in_memory_warnings_enabled) || @in_memory_warnings_enabled.nil?
    return true
  end
  return @in_memory_warnings_enabled
end

#retry_attemptsFixnum

Gets the number of retry attempts.

Returns:

  • (Fixnum)


87
88
89
# File 'lib/vault/rails/configurable.rb', line 87

def retry_attempts
  @retry_attempts ||= 0
end

#retry_attempts=(val) ⇒ Object

Sets the number of retry attempts. Please see the Vault documentation for more information.

Parameters:

  • val (Fixnum)


95
96
97
# File 'lib/vault/rails/configurable.rb', line 95

def retry_attempts=(val)
  @retry_attempts = val
end

#retry_baseFixnum

Gets the number of retry attempts.

Returns:

  • (Fixnum)


102
103
104
# File 'lib/vault/rails/configurable.rb', line 102

def retry_base
  @retry_base ||= Vault::Defaults::RETRY_BASE
end

#retry_base=(val) ⇒ Object

Sets the retry interval. Please see the Vault documentation for more information.

Parameters:

  • val (Fixnum)


110
111
112
# File 'lib/vault/rails/configurable.rb', line 110

def retry_base=(val)
  @retry_base = val
end

#retry_max_waitFixnum

Gets the retry maximum wait.

Returns:

  • (Fixnum)


117
118
119
# File 'lib/vault/rails/configurable.rb', line 117

def retry_max_wait
  @retry_max_wait ||= Vault::Defaults::RETRY_MAX_WAIT
end

#retry_max_wait=(val) ⇒ Object

Sets the maximum amount of time for a single retry. Please see the Vault documentation for more information.

Parameters:

  • val (Fixnum)


125
126
127
# File 'lib/vault/rails/configurable.rb', line 125

def retry_max_wait=(val)
  @retry_max_wait = val
end