chef-server-api 0.9.6 → 0.9.8.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +3 -2
- data/app/controllers/application.rb +30 -22
- data/app/helpers/tarball_helper.rb +0 -4
- data/bin/chef-server +7 -0
- data/config.ru +21 -0
- data/config/environments/development.rb +27 -3
- data/config/init.rb +16 -18
- data/config/rack.rb +18 -0
- data/config/router.rb +19 -0
- data/development.ru +30 -0
- data/lib/chef-server-api/version.rb +1 -1
- metadata +22 -14
data/Rakefile
CHANGED
@@ -21,7 +21,7 @@ spec = Gem::Specification.new do |s|
|
|
21
21
|
s.version = ChefServerApi::VERSION
|
22
22
|
s.platform = Gem::Platform::RUBY
|
23
23
|
s.has_rdoc = true
|
24
|
-
s.extra_rdoc_files = ["README.rdoc", "LICENSE" ]
|
24
|
+
s.extra_rdoc_files = ["README.rdoc", "LICENSE", "config.ru", "development.ru" ]
|
25
25
|
s.summary = SUMMARY
|
26
26
|
s.description = s.summary
|
27
27
|
s.author = AUTHOR
|
@@ -29,11 +29,12 @@ spec = Gem::Specification.new do |s|
|
|
29
29
|
s.homepage = HOMEPAGE
|
30
30
|
|
31
31
|
s.add_dependency "merb-core", "~> 1.1.0"
|
32
|
-
s.add_dependency "merb-slices", "~> 1.1.0"
|
33
32
|
s.add_dependency "merb-assets", "~> 1.1.0"
|
34
33
|
s.add_dependency "merb-helpers", "~> 1.1.0"
|
35
34
|
s.add_dependency "merb-param-protection", "~> 1.1.0"
|
36
35
|
|
36
|
+
s.add_dependency "mixlib-authentication", '>= 1.1.3'
|
37
|
+
|
37
38
|
s.add_dependency "json", "<= 1.4.2"
|
38
39
|
|
39
40
|
s.add_dependency "uuidtools", "~> 2.1.1"
|
@@ -28,28 +28,36 @@ class Application < Merb::Controller
|
|
28
28
|
include Chef::Mixin::Checksum
|
29
29
|
|
30
30
|
def authenticate_every
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
31
|
+
begin
|
32
|
+
# Raises an error if required auth headers are missing
|
33
|
+
authenticator = Mixlib::Authentication::SignatureVerification.new(request)
|
34
|
+
|
35
|
+
username = authenticator.user_id
|
36
|
+
Chef::Log.info("Authenticating client #{username}")
|
37
|
+
|
38
|
+
user = Chef::ApiClient.cdb_load(username)
|
39
|
+
user_key = OpenSSL::PKey::RSA.new(user.public_key)
|
40
|
+
Chef::Log.debug "Authenticating Client:\n #{user.inspect}\n"
|
41
|
+
|
42
|
+
# Store this for later..
|
43
|
+
@auth_user = user
|
44
|
+
authenticator.authenticate_request(user_key)
|
45
|
+
rescue Mixlib::Authentication::MissingAuthenticationHeader => e
|
46
|
+
Chef::Log.debug "Authentication failed: #{e.class.name}: #{e.message}\n#{e.backtrace.join("\n")}"
|
47
|
+
raise Unauthorized, "#{e.class.name}: #{e.message}"
|
48
|
+
rescue StandardError => se
|
49
|
+
Chef::Log.debug "Authentication failed: #{se}, #{se.backtrace.join("\n")}"
|
50
|
+
raise Unauthorized, "Failed to authenticate. Ensure that your client key is valid."
|
51
|
+
end
|
52
|
+
|
53
|
+
unless authenticator.valid_request?
|
54
|
+
if authenticator.valid_timestamp?
|
55
|
+
raise Unauthorized, "Failed to authenticate. Ensure that your client key is valid."
|
56
|
+
else
|
57
|
+
raise Unauthorized, "Failed to authenticate. Please synchronize the clock on your client"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
true
|
53
61
|
end
|
54
62
|
|
55
63
|
def is_admin
|
@@ -70,10 +70,6 @@ module Merb
|
|
70
70
|
File.join(cookbook_base, cookbook_name)
|
71
71
|
end
|
72
72
|
|
73
|
-
def cookbook_tarball_location(cookbook_name)
|
74
|
-
File.join(Chef::Config.cookbook_tarball_path, "#{cookbook_name}.tar.gz")
|
75
|
-
end
|
76
|
-
|
77
73
|
def get_or_create_cookbook_tarball_location(cookbook_name)
|
78
74
|
tarball_location = cookbook_tarball_location(cookbook_name)
|
79
75
|
unless File.exists? tarball_location
|
data/bin/chef-server
CHANGED
@@ -27,6 +27,13 @@ require "merb-core"
|
|
27
27
|
$:.unshift(File.expand_path(File.dirname(__FILE__) + '/../../chef/lib/'))
|
28
28
|
$:.unshift(File.expand_path(File.dirname(__FILE__) + '/../lib'))
|
29
29
|
|
30
|
+
# Print the version if we have -v or --version
|
31
|
+
if ARGV.any? { |arg| arg =~ /\-v|\-\-version/ }
|
32
|
+
require 'chef-server-api/version'
|
33
|
+
puts "Chef Server (API) Version: #{ChefServerApi::VERSION}"
|
34
|
+
exit 1
|
35
|
+
end
|
36
|
+
|
30
37
|
require 'chef'
|
31
38
|
require 'chef-server-api'
|
32
39
|
|
data/config.ru
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'merb-core'
|
3
|
+
require 'chef'
|
4
|
+
|
5
|
+
Chef::Config.from_file(File.join("/etc", "chef", "server.rb"))
|
6
|
+
|
7
|
+
Merb::Config.setup(:merb_root => File.expand_path(File.dirname(__FILE__)),
|
8
|
+
:environment => 'production',
|
9
|
+
:fork_for_class_load => false,
|
10
|
+
:init_file => File.dirname(__FILE__) / "config/init.rb")
|
11
|
+
Merb.environment = Merb::Config[:environment]
|
12
|
+
Merb.root = Merb::Config[:merb_root]
|
13
|
+
Merb::BootLoader.run
|
14
|
+
|
15
|
+
# Uncomment if your app is mounted at a suburi
|
16
|
+
#if prefix = ::Merb::Config[:path_prefix]
|
17
|
+
# use Merb::Rack::PathPrefix, prefix
|
18
|
+
#end
|
19
|
+
|
20
|
+
run Merb::Rack::Application.new
|
21
|
+
|
@@ -1,6 +1,30 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Daniel DeLeo (<dan@opscode.com>)
|
3
|
+
# Copyright:: Copyright (c) 2010 Opscode, Inc.
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
Chef::Log.info("")
|
20
|
+
Chef::Log.info("*" * 80)
|
21
|
+
Chef::Log.info("* Starting Chef Server in Development Mode.")
|
22
|
+
Chef::Log.info("* Start the server with `-e production` for normal use")
|
23
|
+
Chef::Log.info("*" * 80)
|
24
|
+
Chef::Log.info("")
|
25
|
+
|
1
26
|
Merb::Config.use do |c|
|
2
27
|
c[:exception_details] = true
|
3
|
-
c[:reload_classes] = true
|
28
|
+
c[:reload_classes] = true
|
29
|
+
c[:log_level] = :debug
|
4
30
|
end
|
5
|
-
|
6
|
-
Merb.logger.level = :debug
|
data/config/init.rb
CHANGED
@@ -1,24 +1,20 @@
|
|
1
1
|
#
|
2
|
-
#
|
2
|
+
# Author:: Adam Jacob (<adam@opscode.com>)
|
3
|
+
# Author:: Daniel DeLeo (<dan@opscode.com>)
|
4
|
+
# Copyright:: Copyright (c) 2008-2010 Opscode, Inc.
|
5
|
+
# License:: Apache License, Version 2.0
|
3
6
|
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
# run 'slice' from its directory. The 'slice' command is very similar to
|
8
|
-
# the 'merb' command, and takes all the same options, including -i to drop
|
9
|
-
# into an irb session for example.
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
10
|
#
|
11
|
-
#
|
12
|
-
# including use_orm and before_app_loads/after_app_loads.
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
13
12
|
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
19
|
-
# differs by the fact that seamlessly integrates into a so called 'host'
|
20
|
-
# application, which in turn can override or finetune the slice implementation
|
21
|
-
# code and views.
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
22
18
|
#
|
23
19
|
|
24
20
|
require 'merb-assets'
|
@@ -51,11 +47,13 @@ Mixlib::Authentication::Log.logger = Ohai::Log.logger = Chef::Log.logger
|
|
51
47
|
use_template_engine :haml
|
52
48
|
|
53
49
|
Merb::Config.use do |c|
|
50
|
+
c[:name] = "chef-server (api)"
|
51
|
+
c[:fork_for_class_load] = false
|
54
52
|
c[:session_id_key] = '_chef_server_session_id'
|
55
53
|
c[:session_secret_key] = Chef::Config.manage_secret_key
|
56
54
|
c[:session_store] = 'cookie'
|
57
55
|
c[:exception_details] = true
|
58
|
-
c[:reload_classes] =
|
56
|
+
c[:reload_classes] = false
|
59
57
|
c[:log_level] = Chef::Config[:log_level]
|
60
58
|
if Chef::Config[:log_location].kind_of?(String)
|
61
59
|
c[:log_file] = Chef::Config[:log_location]
|
data/config/rack.rb
CHANGED
@@ -1,3 +1,21 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Daniel DeLeo (<dan@opscode.com>)
|
3
|
+
# Copyright:: Copyright (c) 2010 Opscode, Inc.
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
1
19
|
# Correctly set a content length.
|
2
20
|
use Rack::ContentLength
|
3
21
|
|
data/config/router.rb
CHANGED
@@ -1,3 +1,22 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Adam Jacob (<adam@opscode.com>)
|
3
|
+
# Author:: Daniel DeLeo (<dan@opscode.com>)
|
4
|
+
# Copyright:: Copyright (c) 2008-2010 Opscode, Inc.
|
5
|
+
# License:: Apache License, Version 2.0
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
#
|
19
|
+
|
1
20
|
Merb::Router.prepare do
|
2
21
|
resources :users
|
3
22
|
|
data/development.ru
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
|
3
|
+
$:.unshift(File.dirname(__FILE__) + '/../chef/lib')
|
4
|
+
|
5
|
+
require 'merb-core'
|
6
|
+
require 'chef'
|
7
|
+
|
8
|
+
#Chef::Config.from_file(File.join("/etc", "chef", "server.rb"))
|
9
|
+
Chef::Config.from_file(File.dirname(__FILE__) + '/../features/data/config/server.rb')
|
10
|
+
|
11
|
+
Chef::Config[:log_location] = '/tmp/fuuu'
|
12
|
+
Chef::Config[:log_level] = :debug
|
13
|
+
Chef::Log.level = :debug
|
14
|
+
|
15
|
+
Merb::Config.setup(:merb_root => File.expand_path(File.dirname(__FILE__)),
|
16
|
+
:environment => 'development',
|
17
|
+
:fork_for_class_load => false,
|
18
|
+
:init_file => File.dirname(__FILE__) / "config/init.rb")
|
19
|
+
Merb.environment = Merb::Config[:environment]
|
20
|
+
Merb.root = Merb::Config[:merb_root]
|
21
|
+
|
22
|
+
Merb::BootLoader.run
|
23
|
+
|
24
|
+
# Uncomment if your app is mounted at a suburi
|
25
|
+
#if prefix = ::Merb::Config[:path_prefix]
|
26
|
+
# use Merb::Rack::PathPrefix, prefix
|
27
|
+
#end
|
28
|
+
|
29
|
+
run Merb::Rack::Application.new
|
30
|
+
|
metadata
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chef-server-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
4
|
+
prerelease: true
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 9
|
8
|
-
-
|
9
|
-
|
8
|
+
- 8
|
9
|
+
- beta
|
10
|
+
- 1
|
11
|
+
version: 0.9.8.beta.1
|
10
12
|
platform: ruby
|
11
13
|
authors:
|
12
14
|
- Opscode
|
@@ -14,7 +16,7 @@ autorequire:
|
|
14
16
|
bindir: bin
|
15
17
|
cert_chain: []
|
16
18
|
|
17
|
-
date: 2010-07-
|
19
|
+
date: 2010-07-23 00:00:00 -07:00
|
18
20
|
default_executable:
|
19
21
|
dependencies:
|
20
22
|
- !ruby/object:Gem::Dependency
|
@@ -33,7 +35,7 @@ dependencies:
|
|
33
35
|
prerelease: false
|
34
36
|
version_requirements: *id001
|
35
37
|
- !ruby/object:Gem::Dependency
|
36
|
-
name: merb-
|
38
|
+
name: merb-assets
|
37
39
|
requirement: &id002 !ruby/object:Gem::Requirement
|
38
40
|
none: false
|
39
41
|
requirements:
|
@@ -48,7 +50,7 @@ dependencies:
|
|
48
50
|
prerelease: false
|
49
51
|
version_requirements: *id002
|
50
52
|
- !ruby/object:Gem::Dependency
|
51
|
-
name: merb-
|
53
|
+
name: merb-helpers
|
52
54
|
requirement: &id003 !ruby/object:Gem::Requirement
|
53
55
|
none: false
|
54
56
|
requirements:
|
@@ -63,7 +65,7 @@ dependencies:
|
|
63
65
|
prerelease: false
|
64
66
|
version_requirements: *id003
|
65
67
|
- !ruby/object:Gem::Dependency
|
66
|
-
name: merb-
|
68
|
+
name: merb-param-protection
|
67
69
|
requirement: &id004 !ruby/object:Gem::Requirement
|
68
70
|
none: false
|
69
71
|
requirements:
|
@@ -78,17 +80,17 @@ dependencies:
|
|
78
80
|
prerelease: false
|
79
81
|
version_requirements: *id004
|
80
82
|
- !ruby/object:Gem::Dependency
|
81
|
-
name:
|
83
|
+
name: mixlib-authentication
|
82
84
|
requirement: &id005 !ruby/object:Gem::Requirement
|
83
85
|
none: false
|
84
86
|
requirements:
|
85
|
-
- -
|
87
|
+
- - ">="
|
86
88
|
- !ruby/object:Gem::Version
|
87
89
|
segments:
|
88
90
|
- 1
|
89
91
|
- 1
|
90
|
-
-
|
91
|
-
version: 1.1.
|
92
|
+
- 3
|
93
|
+
version: 1.1.3
|
92
94
|
type: :runtime
|
93
95
|
prerelease: false
|
94
96
|
version_requirements: *id005
|
@@ -144,6 +146,8 @@ extensions: []
|
|
144
146
|
extra_rdoc_files:
|
145
147
|
- README.rdoc
|
146
148
|
- LICENSE
|
149
|
+
- config.ru
|
150
|
+
- development.ru
|
147
151
|
files:
|
148
152
|
- LICENSE
|
149
153
|
- README.rdoc
|
@@ -192,6 +196,8 @@ files:
|
|
192
196
|
- public/stylesheets/themes/orange/style.css
|
193
197
|
- public/stylesheets/themes/reidb-greenish/style.css
|
194
198
|
- bin/chef-server
|
199
|
+
- config.ru
|
200
|
+
- development.ru
|
195
201
|
has_rdoc: true
|
196
202
|
homepage: http://wiki.opscode.com/display/chef
|
197
203
|
licenses: []
|
@@ -212,11 +218,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
212
218
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
213
219
|
none: false
|
214
220
|
requirements:
|
215
|
-
- - "
|
221
|
+
- - ">"
|
216
222
|
- !ruby/object:Gem::Version
|
217
223
|
segments:
|
218
|
-
-
|
219
|
-
|
224
|
+
- 1
|
225
|
+
- 3
|
226
|
+
- 1
|
227
|
+
version: 1.3.1
|
220
228
|
requirements: []
|
221
229
|
|
222
230
|
rubyforge_project:
|