# 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.
Corylus::Application.config.secret_token = '84299a2b328da7bdf9e9eda1e11ea4fd47c7de816c8c38ab6fd214ac4e3c47e6d20f2d4c48ad082a6d92104347ffeed89106a8a246adc1630dbde06ce588114a'

# Corylus - ERP software
# Copyright (c) 2005-2014 François Tigeot
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in the
#    documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.

# Storing the Ruby on Rails secret token in this file is madness. Put it in
# a real configuration file and auto-generate it on startup if missing.
# This code was inspired from this blog entry from Michael Hartl:
# http://blog.mhartl.com/2008/08/15/a-security-issue-with-rails-secret-session-keys/

secret_file = File.join(Rails.root, 'secret-token.txt')

if File.exist?(secret_file)
  secret = File.read(secret_file)
else
  chars = ('0'..'9').to_a + ('a'..'f').to_a
  secret = ''
  1.upto(64) { |i| secret << chars[rand(chars.size-1)] }
  File.open(secret_file, 'w') { |f| f.write(secret) }
end

Corylus::Application.config.secret_token = secret

Put the secret token into a separate file
Config: Put the secret token into a separate file

* Having it into the source code is madness. Use an installation-specific
  configuration file to store it

* If this file is not found during application startup, Corylus will
  generate a new secret token

This code was inspired from this blog entry from Michael Hartl:
http://blog.mhartl.com/2008/08/15/a-security-issue-with-rails-secret-session-keys/
