summaryrefslogtreecommitdiff
path: root/config
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dzaporozhets@gitlab.com>2014-10-20 10:47:43 +0000
committerDmitriy Zaporozhets <dzaporozhets@gitlab.com>2014-10-20 10:47:43 +0000
commitab2db486b8014e509455b624dfd1719f77e27ede (patch)
treee0ad46182e7b86946e3c2790ce7e6f9d95964358 /config
parentd4bc1255817e6cdab95596096067bdc611b71280 (diff)
parent2e485af7b051512f804ae46a81cba480d2eca46f (diff)
downloadgitlab-ce-ab2db486b8014e509455b624dfd1719f77e27ede.tar.gz
Merge branch 'security-api-internal-publicity' into 'master'
Gitlab-shell identification Part of gitlab/gitlabhq#1528 See merge request !1185
Diffstat (limited to 'config')
-rw-r--r--config/initializers/gitlab_shell_secret_token.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/config/initializers/gitlab_shell_secret_token.rb b/config/initializers/gitlab_shell_secret_token.rb
new file mode 100644
index 00000000000..8d2b771e535
--- /dev/null
+++ b/config/initializers/gitlab_shell_secret_token.rb
@@ -0,0 +1,19 @@
+# Be sure to restart your server when you modify this file.
+
+require 'securerandom'
+
+# Your secret key for verifying the gitlab_shell.
+
+
+secret_file = Rails.root.join('.gitlab_shell_secret')
+gitlab_shell_symlink = File.join(Gitlab.config.gitlab_shell.path, '.gitlab_shell_secret')
+
+unless File.exist? secret_file
+ # Generate a new token of 16 random hexadecimal characters and store it in secret_file.
+ token = SecureRandom.hex(16)
+ File.write(secret_file, token)
+end
+
+if File.exist?(Gitlab.config.gitlab_shell.path) && !File.exist?(gitlab_shell_symlink)
+ FileUtils.symlink(secret_file, gitlab_shell_symlink)
+end \ No newline at end of file