Skip to content

Commit 926941a

Browse files
committed
Updating the session key generation, working on Chef logging via merb
1 parent 4faf732 commit 926941a

1 file changed

Lines changed: 16 additions & 5 deletions

File tree

chef-server/lib/init.rb

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@
137137
# use_test :test_unit
138138
use_test :rspec
139139

140-
141140
#
142141
# ==== Set up your basic configuration
143142
#
@@ -146,15 +145,27 @@
146145
# Sets up a custom session id key, if you want to piggyback sessions of other applications
147146
# with the cookie session store. If not specified, defaults to '_session_id'.
148147
c[:session_id_key] = '_chef_server_session_id'
149-
c[:session_secret_key] = '0992ea491c30ec76c98367c1ca53b18c1e7c5b30'
148+
149+
newpass = nil
150+
if Chef::FileCache.has_key?("chef_server_cookie_id")
151+
newpass = Chef::FileCache.load("chef_server_cookie_id")
152+
else
153+
chars = ("a".."z").to_a + ("A".."Z").to_a + ("0".."9").to_a
154+
newpass = ""
155+
1.upto(40) { |i| newpass << chars[rand(chars.size-1)] }
156+
Chef::FileCache.store("chef_server_cookie_id", newpass)
157+
end
158+
159+
c[:session_secret_key] = newpass
150160
c[:session_store] = 'cookie'
151161
c[:exception_details] = true
152162
c[:reload_classes] = false
153-
c[:log_level] = :debug
154-
c[:log_stream] = STDOUT
163+
c[:log_level] = Chef::Config[:log_level]
164+
c[:log_stream] = Chef::Config[:log_location]
155165
end
156166

157-
Chef::Log.info("Compiling routes...")
167+
Chef::Log.logger = Merb.logger
168+
Chef::Log.error("Compiling routes...")
158169
Merb::Router.prepare do |r|
159170
# RESTful routes
160171
# r.resources :posts

0 commit comments

Comments
 (0)