Class: Chef::Config

Inherits:
Object show all
Extended by:
Mixlib::Config
Defined in:
lib/chef/config.rb

Class Method Summary collapse

Class Method Details

.manage_secret_keyObject

Manages the chef secret session key

Returns

<newkey>

A new or retrieved session key



32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/chef/config.rb', line 32

def self.manage_secret_key
  newkey = nil
  if Chef::FileCache.has_key?("chef_server_cookie_id")
    newkey = Chef::FileCache.load("chef_server_cookie_id")
  else
    chars = ("a".."z").to_a + ("A".."Z").to_a + ("0".."9").to_a
    newkey = ""
    40.times { |i| newkey << chars[rand(chars.size-1)] }
    Chef::FileCache.store("chef_server_cookie_id", newkey)
  end
  newkey
end