conjur-api 5.2.1 → 5.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e48184760d9c40ab8a43ffeb451c3f733ba23cbe0cdb364efd13ac6183b68055
4
- data.tar.gz: e31f3fee9f4f75038da1b3ad3ffcad72e5005c758b2fc1fc52cf00e0bc9deff1
3
+ metadata.gz: a3a19d6390e7e021ec28db797635aacc7ebbaf3e23a9142cf0fe6a028fefd1bc
4
+ data.tar.gz: 62f3ea9b7e62e32e69eff388c1d46b7678a5ba715a813a473a82c0d7d1c5fe29
5
5
  SHA512:
6
- metadata.gz: 7a215e37eda9fb96db4c2554d02fd88a862b7a34865fad86c080314b217bca494b88a0a3b431f49f6b06476c3bd17ab0ed6c678db7ab42c7c5310936fde75361
7
- data.tar.gz: 2b381514ef1d02855e6ce96b635738b7ee0bcfc7b12367eca924d8e1cade02d45ebc8f8911cdd7d98b030d772d16b217859badc5885cc37d370829288b52f843
6
+ metadata.gz: e2343a406b582f16d10eab5f876774fb8dce4376d9c0908599a8ed38f863ac2e36091285cb43f47d361d10cca0362a0e6f22b1ced655521054143fd25d5d82ba
7
+ data.tar.gz: 5d32c7db4693c2d33460e9932e9521d94751d95d94bb19a494b0b0f5198f674eeefaf5e169eb026f5f2a00388aa449fb19437fe2ae0add72937c7dfa1d0a5e90
@@ -1,5 +1,9 @@
1
1
  # Latest
2
2
 
3
+ # v5.3.0
4
+
5
+ * Add `Conjur::API.ldap_sync_policy` for fetching the LDAP sync policy.
6
+
3
7
  # v5.2.1
4
8
 
5
9
  * Fix `Conjur::BuildObject#build_object` so it only tries to create
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # Conjur::API
2
2
 
3
- Programmatic Ruby access to the Conjur API.
3
+ Programmatic Ruby access to the Conjur API.
4
+
5
+ RDocs are available from the through the [Ruby Gem details page](https://rubygems.org/gems/conjur-api)
4
6
 
5
7
  # Server Versions
6
8
 
@@ -47,11 +49,7 @@ Connecting to Conjur is a two-step process:
47
49
 
48
50
  The simplest way to configure the Conjur API is to use the configuration file stored on the machine.
49
51
  If you have configured the machine with [conjur init](http://developer.conjur.net/reference/tools/init.html),
50
- <<<<<<< HEAD
51
52
  its default location is `~/.conjurrc`.
52
- =======
53
- it's default location is `~/.conjurrc`.
54
- >>>>>>> Added development environment
55
53
 
56
54
  The Conjur configuration process also checks `/etc/conjur.conf` for global settings. This is typically used
57
55
  in server environments.
@@ -19,6 +19,6 @@
19
19
 
20
20
  module Conjur
21
21
  class API
22
- VERSION = "5.2.1"
22
+ VERSION = "5.3.0"
23
23
  end
24
24
  end
@@ -41,6 +41,7 @@ require 'conjur/api/pubkeys'
41
41
  require 'conjur/api/variables'
42
42
  require 'conjur/api/policies'
43
43
  require 'conjur/api/host_factories'
44
+ require 'conjur/api/ldap_sync'
44
45
  require 'conjur/host'
45
46
  require 'conjur/group'
46
47
  require 'conjur/variable'
@@ -0,0 +1,38 @@
1
+ #
2
+ # Copyright 2013-2018 Conjur Inc
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining a copy of
5
+ # this software and associated documentation files (the "Software"), to deal in
6
+ # the Software without restriction, including without limitation the rights to
7
+ # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
8
+ # the Software, and to permit persons to whom the Software is furnished to do so,
9
+ # subject to the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be included in all
12
+ # copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
16
+ # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
17
+ # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
18
+ # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19
+ # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20
+ #
21
+
22
+ module Conjur
23
+ class API
24
+
25
+ # Retrieve the policy for the given LDAP sync
26
+ # configuration. Configurations created through the Conjur UI are
27
+ # named +default+, so the default value of +config_name+ can be
28
+ # used.
29
+ #
30
+ # For details on the use of LDAP sync, see
31
+ # https://developer.conjur.net/reference/services/ldap_sync/ .
32
+ #
33
+ # @param [String] config_name the name of the LDAP sync configuration.
34
+ def ldap_sync_policy config_name: 'default'
35
+ JSON.parse(url_for(:ldap_sync_policy, credentials, config_name).get)
36
+ end
37
+ end
38
+ end
@@ -139,6 +139,10 @@ module Conjur
139
139
  end
140
140
  end
141
141
 
142
+ def ldap_sync_policy(credentials, config_name)
143
+ RestClient::Resource.new(Conjur.configuration.core_url, credentials)['ldap-sync']["policy?config_name=#{fully_escape(config_name)}"]
144
+ end
145
+
142
146
  private
143
147
 
144
148
  def resource_annotations resource
@@ -71,11 +71,14 @@ module Conjur
71
71
  @attributes = nil
72
72
  end
73
73
 
74
-
74
+ def annotations
75
+ Hash[(attributes['annotations']||{}).collect {|e| [e['name'],e['value']]}]
76
+ end
77
+
75
78
  protected
76
79
 
77
80
  def annotation_value name
78
- HasAttributes.annotation_value attributes['annotations'], name
81
+ annotations[name]
79
82
  end
80
83
 
81
84
  # @api private
@@ -92,4 +95,4 @@ module Conjur
92
95
  end
93
96
  end
94
97
  end
95
- end
98
+ end
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ describe Conjur::API, api: :dummy do
4
+ let(:router) { double('router', :get => "{}") }
5
+ before do
6
+ allow_any_instance_of(Conjur::API).to receive(:url_for).with(:ldap_sync_policy, any_args).and_return(router)
7
+ end
8
+
9
+ # verify that the method exists, and takes the correct argument.
10
+ describe '#ldap_sync_policy' do
11
+ context 'with default config' do
12
+ subject { api.ldap_sync_policy }
13
+ it { is_expected.to eq({}) }
14
+ end
15
+
16
+ context 'with a config specified' do
17
+ subject { api.ldap_sync_policy config_name: 'non-default-config' }
18
+ it { is_expected.to eq({}) }
19
+ end
20
+ end
21
+ 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: 5.2.1
4
+ version: 5.3.0
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: 2018-06-14 00:00:00.000000000 Z
12
+ date: 2018-06-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest-client
@@ -286,6 +286,7 @@ files:
286
286
  - lib/conjur/api.rb
287
287
  - lib/conjur/api/authn.rb
288
288
  - lib/conjur/api/host_factories.rb
289
+ - lib/conjur/api/ldap_sync.rb
289
290
  - lib/conjur/api/policies.rb
290
291
  - lib/conjur/api/pubkeys.rb
291
292
  - lib/conjur/api/resources.rb
@@ -331,6 +332,7 @@ files:
331
332
  - spec/has_attributes_spec.rb
332
333
  - spec/helpers/errors_matcher.rb
333
334
  - spec/helpers/request_helpers.rb
335
+ - spec/ldap_sync_spec.rb
334
336
  - spec/log_source_spec.rb
335
337
  - spec/log_spec.rb
336
338
  - spec/roles_spec.rb
@@ -398,6 +400,7 @@ test_files:
398
400
  - spec/has_attributes_spec.rb
399
401
  - spec/helpers/errors_matcher.rb
400
402
  - spec/helpers/request_helpers.rb
403
+ - spec/ldap_sync_spec.rb
401
404
  - spec/log_source_spec.rb
402
405
  - spec/log_spec.rb
403
406
  - spec/roles_spec.rb