2017-10-01 13:57:36 +02:00
|
|
|
# Be sure to restart your server when you modify this file.
|
|
|
|
|
|
|
|
# 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.
|
|
|
|
Foodsoft::Application.config.secret_key_base = begin
|
2022-05-27 21:57:06 +02:00
|
|
|
if (token = ENV.fetch('SECRET_KEY_BASE', nil)).present?
|
2017-10-01 13:57:36 +02:00
|
|
|
token
|
|
|
|
elsif Rails.env.production? || Rails.env.staging?
|
2023-05-12 13:01:12 +02:00
|
|
|
raise 'You must set SECRET_KEY_BASE'
|
2017-10-01 13:57:36 +02:00
|
|
|
elsif Rails.env.test?
|
|
|
|
SecureRandom.hex(30) # doesn't really matter
|
|
|
|
else
|
|
|
|
sf = Rails.root.join('tmp', 'secret_key_base')
|
2023-05-12 13:01:12 +02:00
|
|
|
if File.exist?(sf)
|
2017-10-01 13:57:36 +02:00
|
|
|
File.read(sf)
|
|
|
|
else
|
|
|
|
puts "=> Generating initial SECRET_KEY_BASE in #{sf}"
|
|
|
|
token = SecureRandom.hex(30)
|
2022-02-20 16:15:22 +01:00
|
|
|
File.write(sf, token)
|
2017-10-01 13:57:36 +02:00
|
|
|
token
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|