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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 038dcc4d85e30d07b34ca84dda11196b3cbc8a98
4
- data.tar.gz: 7b47721f2a9af64c512c6c2fbc5a5644aa5d98e5
3
+ metadata.gz: f57acfdd94157de9609e46b399c12484591d13c2
4
+ data.tar.gz: a4ecc120203d25a8cfd56d9b01894a61e71d13cd
5
5
  SHA512:
6
- metadata.gz: 9d4dc629522aa37aeea760aa16ec9d9df7694754fe5490f45530de68bcba544a9b35de834288dd4576920a92b800be71fe3a03414397be0e24bd06a954929fe0
7
- data.tar.gz: dafee7953f111a1723a22f9cc0b2a2dacd970e6c10fad46f20458380fb14951ff7ef0e83a09027aa9e3cb20d0fc993a39e6872bfce2fc46e536879ab356f2c73
6
+ metadata.gz: ff668011c790785e3c80eeeccac8a85ee22e6337030f96c58bb69f9c012bce35044c96d33b47ea52ee8d203c65c79f2aebaf5e24355c7f1646eef93cbd947f1c
7
+ data.tar.gz: 547ae4223549ecf0150f861ec7e6736e90933219d9f22f122573f7745dedee3218ebf911b36eb44523bcfd3acad0ca99677582262ee3b27ab7fff9d97e7aa432
@@ -1,3 +1,8 @@
1
+ # v4.28.1
2
+
3
+ * `Conjur::API#ldap_sync_policy` now returns log events generated when
4
+ showing a policy.
5
+
1
6
  # v4.28.0
2
7
 
3
8
  * Add `Conjur::API#ldap_sync_policy` to fetch the policy to use to
@@ -19,6 +19,6 @@
19
19
 
20
20
  module Conjur
21
21
  class API
22
- VERSION = "4.28.0"
22
+ VERSION = "4.28.1"
23
23
  end
24
24
  end
@@ -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
- resp = RestClient::Resource.new(Conjur.configuration.appliance_url, credentials)['ldap-sync']['config'].get(options)
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 find_policy_event(response)
83
- response.body.lines.find {|l| l =~ /^data: {"policy":/}.try(:[], 6..-1)
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.body.lines.collect {|l| l.match(/^data: ({"error":.*)/).try(:[], 1)}.compact.join("\n")
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.0
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-16 00:00:00.000000000 Z
12
+ date: 2016-11-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest-client