Skip to content

Commit

Permalink
consolidate secret setup
Browse files Browse the repository at this point in the history
  • Loading branch information
qrush committed Mar 19, 2012
1 parent b2f691f commit d549a57
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
2 changes: 0 additions & 2 deletions config/environments/maintenance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,3 @@

config.plugins = []
end

require Rails.root.join("config", "secret") if Rails.root.join("config", "secret.rb").file?
2 changes: 0 additions & 2 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,3 @@
# :domain => ENV['SENDGRID_DOMAIN']
# }
end

require Rails.root.join("config", "secret") if Rails.root.join("config", "secret.rb").file?
2 changes: 0 additions & 2 deletions config/environments/staging.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,3 @@
config.serve_static_assets = $rubygems_config[:asset_cacher]
config.i18n.fallbacks = true
end

require Rails.root.join("config", "secret") if Rails.root.join("config", "secret.rb").file?
8 changes: 8 additions & 0 deletions config/initializers/secret_token.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,12 @@
# 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.

if Rails.env.maintenance? || Rails.env.staging? || Rails.env.production?
secret_path = Rails.root.join("config", "secret.rb")
if secret_path.file?
require secret_path.to_s
end
end

Rails.application.config.secret_token = ENV['SECRET_TOKEN'] || '53336f5ffda880aa2f6d5fbb7603b6df4d975408afbf44642d342547c25f92265eb01c34b118ee7fa87475f69949b07b292d95276aae2f6bda029ea25d28dc28'

0 comments on commit d549a57

Please sign in to comment.