smart_proxy_chef 0.1.8 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/smart_proxy_chef_plugin/authentication.rb +8 -1
- data/lib/smart_proxy_chef_plugin/connection_helper.rb +3 -0
- data/lib/smart_proxy_chef_plugin/foreman_api.rb +19 -0
- data/lib/smart_proxy_chef_plugin/request.rb +6 -0
- data/lib/smart_proxy_chef_plugin/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cb1a8d45f99bf8244a5ca235ccb3922e7cbd65df
|
4
|
+
data.tar.gz: 9b3363fe645754749974940d2fc9a826ad5e5ab9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aedec5996cc1cfaa621eccb21407403844cfb9a721fee5febd9310839092e48dbf634d71b62c5588fed52f8ae00a0ba58e823799c92de0be6d106a63597321c8
|
7
|
+
data.tar.gz: d6e9984216441b57692c6f81bccf4e1cbd8b4374572895f19b3c237d127f6a3153463e0dd127decaa0852499897b305972dfb1a79720941800aa5d7219160508
|
@@ -33,7 +33,14 @@ module ChefPlugin
|
|
33
33
|
|
34
34
|
def authenticate_chef_signature(request)
|
35
35
|
logger.debug('starting chef signature authentication')
|
36
|
-
|
36
|
+
case request.request_method
|
37
|
+
when 'POST'
|
38
|
+
content = request.env["rack.input"].read
|
39
|
+
when 'GET'
|
40
|
+
content = request.env['HTTP_X_FOREMAN_CLIENT']
|
41
|
+
else
|
42
|
+
log_halt 401, "Don't know how to authenticate #{request.request_method} requests"
|
43
|
+
end
|
37
44
|
|
38
45
|
auth = true
|
39
46
|
if ChefPlugin::Plugin.settings.chef_authenticate_nodes
|
@@ -1,6 +1,8 @@
|
|
1
1
|
require 'proxy/request'
|
2
2
|
require 'smart_proxy_chef_plugin/request'
|
3
3
|
require 'smart_proxy_chef_plugin/authentication'
|
4
|
+
require 'uri'
|
5
|
+
require 'yaml'
|
4
6
|
|
5
7
|
module ChefPlugin
|
6
8
|
::Sinatra::Base.register Authentication
|
@@ -32,6 +34,23 @@ module ChefPlugin
|
|
32
34
|
log_result(foreman_response)
|
33
35
|
end
|
34
36
|
|
37
|
+
get '/enc/:client' do |client|
|
38
|
+
begin
|
39
|
+
if client != request.env['HTTP_X_FOREMAN_CLIENT']
|
40
|
+
log_halt(401, "Unauthorized : client '#{request.env['HTTP_X_FOREMAN_CLIENT']}' is asking for other client '#{client}' data")
|
41
|
+
end
|
42
|
+
content_type :json
|
43
|
+
result = ChefPlugin::HttpRequest::Hosts.new.host_enc(client)
|
44
|
+
log_result(result)
|
45
|
+
log_halt(500, "Could not fetch ENC for #{client}, see Foreman production.log for more details") unless result.code.to_s.start_with?('2')
|
46
|
+
|
47
|
+
yaml_enc = result.body
|
48
|
+
YAML.load(yaml_enc).to_json
|
49
|
+
rescue => e
|
50
|
+
log_halt 400, e
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
35
54
|
private
|
36
55
|
|
37
56
|
def get_content
|
@@ -13,5 +13,11 @@ module ChefPlugin
|
|
13
13
|
send_request(request_factory.create_post('api/reports', report))
|
14
14
|
end
|
15
15
|
end
|
16
|
+
|
17
|
+
class Hosts < ::Proxy::HttpRequest::ForemanRequest
|
18
|
+
def host_enc(host)
|
19
|
+
send_request(request_factory.create_get("node/#{host}", { :format => 'yml' }))
|
20
|
+
end
|
21
|
+
end
|
16
22
|
end
|
17
23
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smart_proxy_chef
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marek Hulan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -108,7 +108,8 @@ dependencies:
|
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
|
-
description:
|
111
|
+
description: |2
|
112
|
+
Chef support for Foreman Smart-Proxy
|
112
113
|
email:
|
113
114
|
- mhulan@redhat.com
|
114
115
|
executables: []
|
@@ -154,4 +155,3 @@ signing_key:
|
|
154
155
|
specification_version: 4
|
155
156
|
summary: Chef support for Foreman Smart-Proxy
|
156
157
|
test_files: []
|
157
|
-
has_rdoc:
|