summaryrefslogtreecommitdiff
path: root/config
diff options
context:
space:
mode:
authorSean McGivern <sean@mcgivern.me.uk>2018-06-04 11:00:00 +0000
committerSean McGivern <sean@mcgivern.me.uk>2018-06-04 11:00:00 +0000
commitb7244e038139a5c5d6107a776a096a558a403573 (patch)
treee0d522f65d405736855731a0c4770ca85a2be4d6 /config
parent8008442829ea797b822d7c782334f6b2d319ca86 (diff)
parent0b4f9ff4068af6776b495d9332aeecf58e48786f (diff)
downloadgitlab-ce-dm-gitlab-shell-7-1-4.tar.gz
Merge branch 'master' into 'dm-gitlab-shell-7-1-4'dm-gitlab-shell-7-1-4
# Conflicts: # GITLAB_SHELL_VERSION
Diffstat (limited to 'config')
-rw-r--r--config/settings.rb23
1 files changed, 15 insertions, 8 deletions
diff --git a/config/settings.rb b/config/settings.rb
index 58f38d103ea..3f3481bb65d 100644
--- a/config/settings.rb
+++ b/config/settings.rb
@@ -85,17 +85,24 @@ class Settings < Settingslogic
File.expand_path(path, Rails.root)
end
- # Returns a 256-bit key for attr_encrypted
- def attr_encrypted_db_key_base
- # Ruby 2.4+ requires passing in the exact required length for OpenSSL keys
- # (https://github.com/ruby/ruby/commit/ce635262f53b760284d56bb1027baebaaec175d1).
- # Previous versions quietly truncated the input.
- #
- # The default mode for the attr_encrypted gem is to use a 256-bit key.
- # We truncate the 128-byte string to 32 bytes.
+ # Ruby 2.4+ requires passing in the exact required length for OpenSSL keys
+ # (https://github.com/ruby/ruby/commit/ce635262f53b760284d56bb1027baebaaec175d1).
+ # Previous versions quietly truncated the input.
+ #
+ # Use this when using :per_attribute_iv mode for attr_encrypted.
+ # We have to truncate the string to 32 bytes for a 256-bit cipher.
+ def attr_encrypted_db_key_base_truncated
Gitlab::Application.secrets.db_key_base[0..31]
end
+ # This should be used for :per_attribute_salt_and_iv mode. There is no
+ # need to truncate the key because the encryptor will use the salt to
+ # generate a hash of the password:
+ # https://github.com/attr-encrypted/encryptor/blob/c3a62c4a9e74686dd95e0548f9dc2a361fdc95d1/lib/encryptor.rb#L77
+ def attr_encrypted_db_key_base
+ Gitlab::Application.secrets.db_key_base
+ end
+
private
def base_url(config)