Skip to content

Commit 510e2fe

Browse files
committed
Update to remove secret token.
1 parent b0c393d commit 510e2fe

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
1-
# Be sure to restart your server when you modify this file.
1+
if ENV["SECRET_TOKEN"].blank?
2+
if Rails.env.production?
3+
raise "You must set ENV[\"SECRET_TOKEN\"] in your app's config vars"
4+
elsif Rails.env.test?
5+
# Generate the key and test away
6+
ENV["SECRET_TOKEN"] = HacketyHackCom::Application.config.secret_token = SecureRandom.hex(30)
7+
else
8+
config_file = File.expand_path(File.join(Rails.root, '/config/config.yml'))
9+
config = YAML.load_file(config_file)
10+
# Generate the key, set it for the current environment, update the yaml file and move on
11+
ENV["SECRET_TOKEN"] = config[Rails.env]['SECRET_TOKEN'] = SecureRandom.hex(30)
12+
File.open(config_file, 'w') { |file| file.write(config.to_yaml) }
13+
end
14+
end
215

3-
# Your secret key for verifying the integrity of signed cookies.
4-
# If you change this key, all old signed cookies will become invalid!
5-
# Make sure the secret is at least 30 characters and all random,
6-
# no regular words or you'll be exposed to dictionary attacks.
7-
HacketyHackCom::Application.config.secret_token = '855ad4d9d95703179ef4280cd14ec205cb6a1fb2477c11bdf55d80390a8ecae82e4b60a4d9e572f9a83cd4d74cedf32a0592afdf36fc86aff0da766fa866aafd'
16+
HacketyHackCom::Application.config.secret_token = ENV["SECRET_TOKEN"]

0 commit comments

Comments
 (0)