conjur-api 5.2.1 → 5.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +10 -0
- data/.github/CODEOWNERS +10 -0
- data/.github/ISSUE_TEMPLATE/bug.md +42 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +27 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +21 -0
- data/.gitignore +1 -0
- data/.gitleaks.toml +219 -0
- data/.overcommit.yml +16 -0
- data/.rubocop.yml +3 -0
- data/.rubocop_settings.yml +86 -0
- data/.rubocop_todo.yml +709 -0
- data/CHANGELOG.md +358 -177
- data/CONTRIBUTING.md +141 -0
- data/Gemfile +1 -1
- data/Jenkinsfile +27 -29
- data/LICENSE +202 -0
- data/README.md +19 -126
- data/SECURITY.md +42 -0
- data/bin/parse-changelog.sh +12 -0
- data/ci/codeclimate.dockerfile +6 -0
- data/conjur-api.gemspec +4 -1
- data/docker-compose.yml +2 -0
- data/features/authenticators.feature +33 -0
- data/features/host.feature +39 -9
- data/features/step_definitions/api_steps.rb +14 -3
- data/features/step_definitions/policy_steps.rb +40 -0
- data/features/support/env.rb +2 -0
- data/features/update_password.feature +2 -2
- data/features/user.feature +47 -6
- data/features_v4/support/env.rb +2 -0
- data/lib/conjur-api/version.rb +2 -2
- data/lib/conjur/acts_as_role.rb +15 -19
- data/lib/conjur/acts_as_user.rb +5 -1
- data/lib/conjur/api.rb +2 -0
- data/lib/conjur/api/authenticators.rb +35 -0
- data/lib/conjur/api/host_factories.rb +20 -19
- data/lib/conjur/{cast.rb → api/ldap_sync.rb} +14 -17
- data/lib/conjur/api/resources.rb +17 -21
- data/lib/conjur/api/router/v5.rb +39 -7
- data/lib/conjur/base.rb +19 -5
- data/lib/conjur/base_object.rb +31 -26
- data/lib/conjur/build_object.rb +13 -20
- data/lib/conjur/cert_utils.rb +14 -0
- data/lib/conjur/configuration.rb +1 -7
- data/lib/conjur/has_attributes.rb +6 -3
- data/lib/conjur/id.rb +22 -19
- data/lib/conjur/role_grant.rb +13 -18
- data/spec/api/host_factories_spec.rb +34 -0
- data/spec/api_spec.rb +55 -6
- data/spec/base_object_spec.rb +13 -0
- data/spec/cert_utils_spec.rb +92 -0
- data/spec/id_spec.rb +29 -0
- data/spec/ldap_sync_spec.rb +21 -0
- data/spec/spec_helper.rb +3 -0
- data/spec/uri_escape_spec.rb +14 -2
- data/test.sh +23 -1
- metadata +34 -12
- data/LICENSE.md +0 -195
- data/spec/cast_spec.rb +0 -21
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'conjur/webservice'
|
4
|
+
|
5
|
+
module Conjur
|
6
|
+
# API contains each of the methods for access the Conjur API endpoints
|
7
|
+
#-- :reek:DataClump for authenticator identifier fields (name, id, account)
|
8
|
+
class API
|
9
|
+
# @!group Authenticators
|
10
|
+
|
11
|
+
# List all configured authenticators
|
12
|
+
def authenticator_list
|
13
|
+
JSON.parse(url_for(:authenticators).get)
|
14
|
+
end
|
15
|
+
|
16
|
+
# Enables an authenticator in Conjur. The authenticator must be defined and
|
17
|
+
# loaded in Conjur policy prior to enabling it.
|
18
|
+
#
|
19
|
+
# @param [String] authenticator the authenticator type to enable (e.g. authn-k8s)
|
20
|
+
# @param [String] id the service ID of the authenticator to enable
|
21
|
+
def authenticator_enable authenticator, id, account: Conjur.configuration.account
|
22
|
+
url_for(:authenticator, account, authenticator, id, credentials).patch(enabled: true)
|
23
|
+
end
|
24
|
+
|
25
|
+
# Disables an authenticator in Conjur.
|
26
|
+
#
|
27
|
+
# @param [String] authenticator the authenticator type to disable (e.g. authn-k8s)
|
28
|
+
# @param [String] id the service ID of the authenticator to disable
|
29
|
+
def authenticator_disable authenticator, id, account: Conjur.configuration.account
|
30
|
+
url_for(:authenticator, account, authenticator, id, credentials).patch(enabled: false)
|
31
|
+
end
|
32
|
+
|
33
|
+
# @!endgroup
|
34
|
+
end
|
35
|
+
end
|
@@ -1,23 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2013-2018 CyberArk Ltd.
|
1
4
|
#
|
2
|
-
#
|
3
|
-
#
|
4
|
-
#
|
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.
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
13
8
|
#
|
14
|
-
#
|
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.
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
20
10
|
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
21
17
|
require 'conjur/host_factory'
|
22
18
|
|
23
19
|
module Conjur
|
@@ -40,9 +36,14 @@ module Conjur
|
|
40
36
|
# @return [Host]
|
41
37
|
def host_factory_create_host token, id, options = {}
|
42
38
|
token = token.token if token.is_a?(HostFactoryToken)
|
43
|
-
response = url_for(:host_factory_create_host, token)
|
39
|
+
response = url_for(:host_factory_create_host, token)
|
40
|
+
.post(options.merge(id: id)).body
|
41
|
+
|
44
42
|
attributes = JSON.parse(response)
|
45
|
-
|
43
|
+
# in v4 'id' is just the identifier
|
44
|
+
host_id = attributes['roleid'] || attributes['id']
|
45
|
+
|
46
|
+
Host.new(host_id, {}).tap do |host|
|
46
47
|
host.attributes = attributes
|
47
48
|
end
|
48
49
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#
|
2
|
-
# Copyright 2013-
|
2
|
+
# Copyright 2013-2018 Conjur Inc
|
3
3
|
#
|
4
4
|
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
5
5
|
# this software and associated documentation files (the "Software"), to deal in
|
@@ -20,22 +20,19 @@
|
|
20
20
|
#
|
21
21
|
|
22
22
|
module Conjur
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
#
|
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/ .
|
27
32
|
#
|
28
|
-
# @param
|
29
|
-
def
|
30
|
-
|
31
|
-
obj
|
32
|
-
elsif obj.is_a?(Array)
|
33
|
-
obj.join(':')
|
34
|
-
else
|
35
|
-
raise "I don't know how to cast a #{obj.class} to an id"
|
36
|
-
end
|
37
|
-
result = Id.new(result) unless result.is_a?(Id)
|
38
|
-
result
|
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)
|
39
36
|
end
|
40
37
|
end
|
41
|
-
end
|
38
|
+
end
|
data/lib/conjur/api/resources.rb
CHANGED
@@ -1,34 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2013-2018 CyberArk Ltd.
|
1
4
|
#
|
2
|
-
#
|
3
|
-
#
|
4
|
-
#
|
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.
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
13
8
|
#
|
14
|
-
#
|
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.
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
20
10
|
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
21
17
|
require 'conjur/resource'
|
22
18
|
|
23
19
|
module Conjur
|
24
20
|
class API
|
25
21
|
include QueryString
|
26
22
|
include BuildObject
|
27
|
-
|
23
|
+
|
28
24
|
#@!group Resources
|
29
25
|
|
30
|
-
# Find a resource by
|
31
|
-
#
|
26
|
+
# Find a resource by its id.
|
27
|
+
# @note The id given to this method must be fully qualified.
|
32
28
|
#
|
33
29
|
# ### Permissions
|
34
30
|
#
|
@@ -88,7 +84,7 @@ module Conjur
|
|
88
84
|
def resources options = {}
|
89
85
|
options = { host: Conjur.configuration.core_url, credentials: credentials }.merge options
|
90
86
|
options[:account] ||= Conjur.configuration.account
|
91
|
-
|
87
|
+
|
92
88
|
host, credentials, account, kind = options.values_at(*[:host, :credentials, :account, :kind])
|
93
89
|
fail ArgumentError, "host and account are required" unless [host, account].all?
|
94
90
|
%w(host credentials account kind).each do |name|
|
data/lib/conjur/api/router/v5.rb
CHANGED
@@ -1,10 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2017-2018 CyberArk Ltd.
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
# rubocop:disable Metrics/ModuleLength
|
1
18
|
module Conjur
|
2
19
|
class API
|
3
20
|
module Router
|
21
|
+
# V5 translates method arguments to rest-ful API request parameters.
|
22
|
+
# because of this, most of the methods suffer from :reek:LongParameterList:
|
23
|
+
# and :reek:UtilityFunction:
|
4
24
|
module V5
|
5
25
|
extend Conjur::Escape::ClassMethods
|
6
26
|
extend Conjur::QueryString
|
7
|
-
extend Conjur::Cast
|
8
27
|
extend self
|
9
28
|
|
10
29
|
def authn_login account, username, password
|
@@ -15,6 +34,14 @@ module Conjur
|
|
15
34
|
RestClient::Resource.new(Conjur.configuration.authn_url)[fully_escape account][fully_escape username]['authenticate']
|
16
35
|
end
|
17
36
|
|
37
|
+
def authenticator account, authenticator, service_id, credentials
|
38
|
+
RestClient::Resource.new(Conjur.configuration.core_url, credentials)[fully_escape authenticator][fully_escape service_id][fully_escape account]
|
39
|
+
end
|
40
|
+
|
41
|
+
def authenticators
|
42
|
+
RestClient::Resource.new(Conjur.configuration.core_url)['authenticators']
|
43
|
+
end
|
44
|
+
|
18
45
|
# For v5, the authn-local message is a JSON string with account, sub, and optional fields.
|
19
46
|
def authn_authenticate_local username, account, expiration, cidr, &block
|
20
47
|
{ account: account, sub: username }.tap do |params|
|
@@ -28,7 +55,7 @@ module Conjur
|
|
28
55
|
end
|
29
56
|
|
30
57
|
def authn_rotate_api_key credentials, account, id
|
31
|
-
RestClient::Resource.new(Conjur.configuration.core_url, credentials)['authn'][
|
58
|
+
RestClient::Resource.new(Conjur.configuration.core_url, credentials)['authn'][fully_escape account]["api_key?role=#{id}"]
|
32
59
|
end
|
33
60
|
|
34
61
|
def authn_rotate_own_api_key account, username, password
|
@@ -51,18 +78,18 @@ module Conjur
|
|
51
78
|
end
|
52
79
|
|
53
80
|
def policies_load_policy credentials, account, id
|
54
|
-
RestClient::Resource.new(Conjur.configuration.core_url, credentials)['policies'][
|
81
|
+
RestClient::Resource.new(Conjur.configuration.core_url, credentials)['policies'][fully_escape account]['policy'][fully_escape id]
|
55
82
|
end
|
56
83
|
|
57
84
|
def public_keys_for_user account, username
|
58
|
-
RestClient::Resource.new(Conjur.configuration.core_url)['public_keys'][fully_escape account]['user'][
|
85
|
+
RestClient::Resource.new(Conjur.configuration.core_url)['public_keys'][fully_escape account]['user'][fully_escape username]
|
59
86
|
end
|
60
87
|
|
61
88
|
def resources credentials, account, kind, options
|
62
89
|
credentials ||= {}
|
63
90
|
|
64
|
-
path = "/resources/#{
|
65
|
-
path += "/#{
|
91
|
+
path = "/resources/#{fully_escape account}"
|
92
|
+
path += "/#{fully_escape kind}" if kind
|
66
93
|
|
67
94
|
RestClient::Resource.new(Conjur.configuration.core_url, credentials)[path][options_querystring options]
|
68
95
|
end
|
@@ -82,7 +109,7 @@ module Conjur
|
|
82
109
|
options = {}
|
83
110
|
options[:check] = true
|
84
111
|
options[:privilege] = privilege
|
85
|
-
options[:role] =
|
112
|
+
options[:role] = query_escape(Id.new(role)) if role
|
86
113
|
resources_resource(credentials, id)[options_querystring options].get
|
87
114
|
end
|
88
115
|
|
@@ -139,6 +166,10 @@ module Conjur
|
|
139
166
|
end
|
140
167
|
end
|
141
168
|
|
169
|
+
def ldap_sync_policy(credentials, config_name)
|
170
|
+
RestClient::Resource.new(Conjur.configuration.core_url, credentials)['ldap-sync']["policy?config_name=#{fully_escape(config_name)}"]
|
171
|
+
end
|
172
|
+
|
142
173
|
private
|
143
174
|
|
144
175
|
def resource_annotations resource
|
@@ -148,3 +179,4 @@ module Conjur
|
|
148
179
|
end
|
149
180
|
end
|
150
181
|
end
|
182
|
+
# rubocop:enable Metrics/ModuleLength
|
data/lib/conjur/base.rb
CHANGED
@@ -123,19 +123,21 @@ module Conjur
|
|
123
123
|
#
|
124
124
|
# @return [String] the api key, or nil if this instance was created from a token.
|
125
125
|
attr_reader :api_key
|
126
|
-
|
126
|
+
|
127
127
|
#@!attribute [r] remote_ip
|
128
128
|
# An optional IP address to be recorded in the audit record for any actions performed by this API instance.
|
129
129
|
attr_reader :remote_ip
|
130
130
|
|
131
131
|
# The name of the user as which this api instance is authenticated. This is available whether the api
|
132
|
-
# instance was created from credentials or an authentication token.
|
132
|
+
# instance was created from credentials or an authentication token. If the instance was created from
|
133
|
+
# credentials, we will use that value directly otherwise we will attempt to extract the username from
|
134
|
+
# the token (either the old-style data field or the new-style JWT `sub` field).
|
133
135
|
#
|
134
136
|
# @return [String] the login of the current user.
|
135
137
|
def username
|
136
|
-
@username || token['data']
|
138
|
+
@username || token['data'] || jwt_username(token)
|
137
139
|
end
|
138
|
-
|
140
|
+
|
139
141
|
# @api private
|
140
142
|
# used to delegate to host providing subclasses.
|
141
143
|
# @return [String] the host
|
@@ -213,7 +215,7 @@ module Conjur
|
|
213
215
|
@account = account
|
214
216
|
@username = username
|
215
217
|
@api_key = api_key
|
216
|
-
|
218
|
+
|
217
219
|
update_token_born
|
218
220
|
end
|
219
221
|
|
@@ -323,6 +325,18 @@ module Conjur
|
|
323
325
|
|
324
326
|
private
|
325
327
|
|
328
|
+
# Tries to get the username (subject) from a JWT API token by examining
|
329
|
+
# its content.
|
330
|
+
#
|
331
|
+
# @return [String] of the 'sub' payload field from the JWT if present,
|
332
|
+
# otherwise return nil
|
333
|
+
def jwt_username raw_token
|
334
|
+
return nil unless raw_token
|
335
|
+
return nil unless raw_token.include? 'payload'
|
336
|
+
|
337
|
+
JSON.parse(Base64.strict_decode64(raw_token["payload"]))["sub"]
|
338
|
+
end
|
339
|
+
|
326
340
|
# Tries to refresh the token if possible.
|
327
341
|
#
|
328
342
|
# @return [Hash, false] false if the token couldn't be refreshed due to
|
data/lib/conjur/base_object.rb
CHANGED
@@ -1,37 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2013-2018 CyberArk Ltd.
|
1
4
|
#
|
2
|
-
#
|
3
|
-
#
|
4
|
-
#
|
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.
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
13
8
|
#
|
14
|
-
#
|
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.
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
20
10
|
#
|
21
|
-
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
22
16
|
|
23
17
|
module Conjur
|
24
18
|
class BaseObject
|
25
|
-
include Cast
|
26
19
|
include QueryString
|
27
20
|
include LogSource
|
28
21
|
include BuildObject
|
29
22
|
include Routing
|
30
|
-
|
23
|
+
|
31
24
|
attr_reader :id, :credentials
|
32
|
-
|
25
|
+
|
33
26
|
def initialize id, credentials
|
34
|
-
@id =
|
27
|
+
@id = Id.new id
|
35
28
|
@credentials = credentials
|
36
29
|
end
|
37
30
|
|
@@ -41,12 +34,24 @@ module Conjur
|
|
41
34
|
}
|
42
35
|
end
|
43
36
|
|
44
|
-
def account
|
45
|
-
|
46
|
-
|
47
|
-
|
37
|
+
def account
|
38
|
+
id.account
|
39
|
+
end
|
40
|
+
|
41
|
+
def kind
|
42
|
+
id.kind
|
43
|
+
end
|
44
|
+
|
45
|
+
def identifier
|
46
|
+
id.identifier
|
47
|
+
end
|
48
|
+
|
48
49
|
def username
|
49
50
|
credentials[:username] or raise "No username found in credentials"
|
50
51
|
end
|
52
|
+
|
53
|
+
def inspect
|
54
|
+
"<#{self.class.name} id='#{id.to_s}'>"
|
55
|
+
end
|
51
56
|
end
|
52
57
|
end
|
data/lib/conjur/build_object.rb
CHANGED
@@ -1,37 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2013-2018 CyberArk Ltd.
|
1
4
|
#
|
2
|
-
#
|
3
|
-
#
|
4
|
-
#
|
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.
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
13
8
|
#
|
14
|
-
#
|
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.
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
20
10
|
#
|
21
|
-
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
22
16
|
|
23
17
|
module Conjur
|
24
18
|
module BuildObject
|
25
19
|
def self.included base
|
26
20
|
base.module_eval do
|
27
|
-
extend Cast
|
28
21
|
extend ClassMethods
|
29
22
|
end
|
30
23
|
end
|
31
24
|
|
32
25
|
module ClassMethods
|
33
26
|
def build_object id, credentials, default_class:
|
34
|
-
id =
|
27
|
+
id = Id.new id
|
35
28
|
class_name = id.kind.classify.to_sym
|
36
29
|
find_class(class_name, default_class)
|
37
30
|
.new(id, credentials)
|