conjur-api 4.28.0 → 4.28.1
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/CHANGELOG.md +5 -0
- data/lib/conjur-api/version.rb +1 -1
- data/lib/conjur/api/ldapsync.rb +37 -13
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f57acfdd94157de9609e46b399c12484591d13c2
|
|
4
|
+
data.tar.gz: a4ecc120203d25a8cfd56d9b01894a61e71d13cd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ff668011c790785e3c80eeeccac8a85ee22e6337030f96c58bb69f9c012bce35044c96d33b47ea52ee8d203c65c79f2aebaf5e24355c7f1646eef93cbd947f1c
|
|
7
|
+
data.tar.gz: 547ae4223549ecf0150f861ec7e6736e90933219d9f22f122573f7745dedee3218ebf911b36eb44523bcfd3acad0ca99677582262ee3b27ab7fff9d97e7aa432
|
data/CHANGELOG.md
CHANGED
data/lib/conjur-api/version.rb
CHANGED
data/lib/conjur/api/ldapsync.rb
CHANGED
|
@@ -43,13 +43,7 @@ module Conjur
|
|
|
43
43
|
# chunks doesn't buy us much of anything except more complicated
|
|
44
44
|
# client code.
|
|
45
45
|
response = RestClient::Resource.new(url, headers).get
|
|
46
|
-
|
|
47
|
-
json = if response.headers[:content_type] == 'text/event-stream'
|
|
48
|
-
find_policy_event(response) || find_error_events(response)
|
|
49
|
-
else
|
|
50
|
-
%Q({"error": {"message": "Unexpected response from server: #{response.body}"}})
|
|
51
|
-
end
|
|
52
|
-
JSON.parse(json)
|
|
46
|
+
JSON.parse(get_json("policy", response)).merge('events' => find_log_events(response))
|
|
53
47
|
end
|
|
54
48
|
|
|
55
49
|
# @api private
|
|
@@ -58,7 +52,8 @@ module Conjur
|
|
|
58
52
|
# @param [String] profile name
|
|
59
53
|
# @param [Hash] options reserved
|
|
60
54
|
def ldap_sync_show_profile(profile, options = {})
|
|
61
|
-
|
|
55
|
+
url = Conjur.configuration.appliance_url
|
|
56
|
+
resp = RestClient::Resource.new(url, credentials)['ldap-sync']['config'][profile].get(options)
|
|
62
57
|
JSON.parse(resp.body)
|
|
63
58
|
end
|
|
64
59
|
|
|
@@ -70,22 +65,51 @@ module Conjur
|
|
|
70
65
|
#
|
|
71
66
|
# @param [Hash] profile a hash containing the LDAP sync configuration
|
|
72
67
|
# @param [Hash] options reserved
|
|
73
|
-
def ldap_sync_update_profile(profile, options = {})
|
|
68
|
+
def ldap_sync_update_profile(profile_name, profile, options = {})
|
|
74
69
|
options[:json_config] = profile.to_json
|
|
75
|
-
resp = RestClient::Resource.new(Conjur.configuration.appliance_url, credentials)['ldap-sync']['config'].put(options.to_json, :content_type => 'application/json')
|
|
70
|
+
resp = RestClient::Resource.new(Conjur.configuration.appliance_url, credentials)['ldap-sync']['config'][profile_name].put(options.to_json, :content_type => 'application/json')
|
|
76
71
|
JSON.parse(resp.body)
|
|
77
72
|
end
|
|
78
73
|
|
|
74
|
+
# @api private
|
|
75
|
+
# Search using an LDAP sync profile
|
|
76
|
+
#
|
|
77
|
+
# @param [String] profile name
|
|
78
|
+
# @param [Hash] options reserved
|
|
79
|
+
def ldap_sync_search(profile, options = {})
|
|
80
|
+
headers = credentials.dup.tap {|h|
|
|
81
|
+
h[:headers][:accept] = 'text/event-stream'
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
response = RestClient::Resource.new(Conjur.configuration.appliance_url, headers)['ldap-sync']['search'].post(options.merge(:config_name => profile))
|
|
85
|
+
JSON.parse(get_json("groups", response)).merge('events' => find_log_events(response))
|
|
86
|
+
end
|
|
87
|
+
|
|
79
88
|
# @!endgroup
|
|
80
89
|
|
|
81
90
|
private
|
|
82
|
-
def
|
|
83
|
-
response.
|
|
91
|
+
def get_json(key, response)
|
|
92
|
+
if response.headers[:content_type] == 'text/event-stream'
|
|
93
|
+
find_event_by_key(key, response) || find_error_events(response)
|
|
94
|
+
else
|
|
95
|
+
%Q({"error": {"message": "Unexpected response from server: #{response.body}"}})
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def find_event_by_key(key, response)
|
|
100
|
+
response.body.lines.find {|l| l =~ %r(^data: {"#{key}":) }.try(:[], 6..-1)
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
def find_log_events(response)
|
|
104
|
+
find_events(response, 'log').collect { |e| JSON.parse(e)['log'] }
|
|
84
105
|
end
|
|
85
106
|
|
|
86
107
|
def find_error_events(response)
|
|
87
|
-
response
|
|
108
|
+
find_events(response, "error").join("\n")
|
|
88
109
|
end
|
|
89
110
|
|
|
111
|
+
def find_events(response, key)
|
|
112
|
+
response.body.lines.collect {|l| l.match(/^data: ({"#{key}":.*)/).try(:[], 1)}.compact
|
|
113
|
+
end
|
|
90
114
|
end
|
|
91
115
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: conjur-api
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 4.28.
|
|
4
|
+
version: 4.28.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Rafal Rzepecki
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2016-11-
|
|
12
|
+
date: 2016-11-30 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: rest-client
|