summaryrefslogtreecommitdiff
path: root/config/initializers
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-01-29 15:08:59 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-01-29 15:08:59 +0000
commit23288f62da73fb0e30d8e7ce306665e8fda1b932 (patch)
tree2baf1339e4d7c7c35d6b8a52cfb90597a5d4cdf1 /config/initializers
parent7cc6872401eb487ed20dbb9d455f8bb9c97d9e39 (diff)
downloadgitlab-ce-23288f62da73fb0e30d8e7ce306665e8fda1b932.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'config/initializers')
-rw-r--r--config/initializers/attr_encrypted_thread_safe.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/config/initializers/attr_encrypted_thread_safe.rb b/config/initializers/attr_encrypted_thread_safe.rb
new file mode 100644
index 00000000000..be0bb56ffdc
--- /dev/null
+++ b/config/initializers/attr_encrypted_thread_safe.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+# As of v3.1.0, attr_encrypted is not thread-safe because all instances share the same `encrypted_attributes`
+# This was fixed in https://github.com/attr-encrypted/attr_encrypted/commit/d4ca0e2073ca6ba5035997ce25f7fc0b4bfbe39e
+# but no release was made after that so we have to patch it ourselves here
+
+module AttrEncrypted
+ module InstanceMethods
+ def encrypted_attributes
+ @encrypted_attributes ||= begin
+ duplicated = {}
+ self.class.encrypted_attributes.map { |key, value| duplicated[key] = value.dup }
+ duplicated
+ end
+ end
+ end
+end