File: initializers.rake

package info (click to toggle)
redmine 2.5.1-2~bpo70%2B6
  • links: PTS, VCS
  • area: main
  • in suites: wheezy-backports
  • size: 15,140 kB
  • sloc: ruby: 83,365; sh: 544; perl: 287; php: 263; python: 154; makefile: 45
file content (35 lines) | stat: -rw-r--r-- 1,209 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
desc 'Generates a secret token for the application.'
task :generate_secret_token do

ENV['X_DEBIAN_SITEID'] ||= 'default'
ENV['RAILS_ETC'] ||= "/etc/redmine/#{ENV['X_DEBIAN_SITEID']}"
filename = ENV['YML_SESSION_FILENAME'] ? ENV['YML_SESSION_FILENAME'] : 'session.yml'
path = File.join(ENV['RAILS_ETC'] ? ENV['RAILS_ETC'] : File.join(Rails.root, 'config'), filename)
secret = SecureRandom.hex(40)
File.open(path, 'w') do |f|
  f.write <<"EOF"
# This file was generated by 'rake generate_session_store',
# not be made visible to public.
# If you have a load-balancing Redmine cluster, you will need to use the
# same version of this file on each machine. And be sure to restart your
# server when you modify this file.
#
# Your secret key for verifying cookie session data integrity. If you
# change this key, all old sessions 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.

production:
  key: _redmine_#{ENV['X_DEBIAN_SITEID']}
  secret: #{secret}

development:
  key: _redmine_#{ENV['X_DEBIAN_SITEID']}
  secret: #{secret}

test:
  key: _redmine_#{ENV['X_DEBIAN_SITEID']}
  secret: #{secret}
EOF
  end
end