diff options
author | Peter Golm <golm.peter@gmail.com> | 2014-01-09 14:43:05 +0100 |
---|---|---|
committer | Peter Golm <golm.peter@gmail.com> | 2014-01-09 14:43:05 +0100 |
commit | ebc17fae4bd4b911cb15ccdfbba5459ca41eccbf (patch) | |
tree | 5e86656a5c1584eccf99c4ceb932655a5d956d42 | |
parent | 1f838a4f98fafa80ae5cfd7759b883b00870072f (diff) | |
download | gitlab-ci-ebc17fae4bd4b911cb15ccdfbba5459ca41eccbf.tar.gz |
fix: use the same method like in gitlab to generate the secure token
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | config/initializers/secret_token.rb | 19 |
2 files changed, 18 insertions, 2 deletions
@@ -13,3 +13,4 @@ tmp/* .rvmrc coverage/* .ruby-version +.secret
\ No newline at end of file diff --git a/config/initializers/secret_token.rb b/config/initializers/secret_token.rb index ccbda95..4d4329c 100644 --- a/config/initializers/secret_token.rb +++ b/config/initializers/secret_token.rb @@ -1,8 +1,23 @@ # Be sure to restart your server when you modify this file. +require 'securerandom' + # Your secret key for verifying the integrity of signed cookies. # If you change this key, all old signed cookies will become invalid! # Make sure the secret is at least 30 characters and all random, # no regular words or you'll be exposed to dictionary attacks. -GitlabCi::Application.config.secret_token = '41cff934d5a788409310b2b4dc931ca9be9c5113ede94f41d44bf71b403f007d8031efa855d6d111393d33ca839722db98445a1a6f020331a3f43bd29a50c93e' -GitlabCi::Application.config.secret_key_token = '41cff934d5a788409310b2b4dc931ca9be9c5113ede94f41d44bf71b403f007d8031efa855d6d111393d33ca839722db98445a1a6f020331a3f43bd29a50c93e' + +def find_secure_token + token_file = Rails.root.join('.secret') + if File.exist? token_file + # Use the existing token. + File.read(token_file).chomp + else + # Generate a new token of 64 random hexadecimal characters and store it in token_file. + token = SecureRandom.hex(64) + File.write(token_file, token) + token + end +end + +GitlabCi::Application.config.secret_key_base = find_secure_token |