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.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +10 -0
  3. data/.github/CODEOWNERS +10 -0
  4. data/.github/ISSUE_TEMPLATE/bug.md +42 -0
  5. data/.github/ISSUE_TEMPLATE/feature_request.md +27 -0
  6. data/.github/PULL_REQUEST_TEMPLATE.md +21 -0
  7. data/.gitignore +1 -0
  8. data/.gitleaks.toml +219 -0
  9. data/.overcommit.yml +16 -0
  10. data/.rubocop.yml +3 -0
  11. data/.rubocop_settings.yml +86 -0
  12. data/.rubocop_todo.yml +709 -0
  13. data/CHANGELOG.md +358 -177
  14. data/CONTRIBUTING.md +141 -0
  15. data/Gemfile +1 -1
  16. data/Jenkinsfile +27 -29
  17. data/LICENSE +202 -0
  18. data/README.md +19 -126
  19. data/SECURITY.md +42 -0
  20. data/bin/parse-changelog.sh +12 -0
  21. data/ci/codeclimate.dockerfile +6 -0
  22. data/conjur-api.gemspec +4 -1
  23. data/docker-compose.yml +2 -0
  24. data/features/authenticators.feature +33 -0
  25. data/features/host.feature +39 -9
  26. data/features/step_definitions/api_steps.rb +14 -3
  27. data/features/step_definitions/policy_steps.rb +40 -0
  28. data/features/support/env.rb +2 -0
  29. data/features/update_password.feature +2 -2
  30. data/features/user.feature +47 -6
  31. data/features_v4/support/env.rb +2 -0
  32. data/lib/conjur-api/version.rb +2 -2
  33. data/lib/conjur/acts_as_role.rb +15 -19
  34. data/lib/conjur/acts_as_user.rb +5 -1
  35. data/lib/conjur/api.rb +2 -0
  36. data/lib/conjur/api/authenticators.rb +35 -0
  37. data/lib/conjur/api/host_factories.rb +20 -19
  38. data/lib/conjur/{cast.rb → api/ldap_sync.rb} +14 -17
  39. data/lib/conjur/api/resources.rb +17 -21
  40. data/lib/conjur/api/router/v5.rb +39 -7
  41. data/lib/conjur/base.rb +19 -5
  42. data/lib/conjur/base_object.rb +31 -26
  43. data/lib/conjur/build_object.rb +13 -20
  44. data/lib/conjur/cert_utils.rb +14 -0
  45. data/lib/conjur/configuration.rb +1 -7
  46. data/lib/conjur/has_attributes.rb +6 -3
  47. data/lib/conjur/id.rb +22 -19
  48. data/lib/conjur/role_grant.rb +13 -18
  49. data/spec/api/host_factories_spec.rb +34 -0
  50. data/spec/api_spec.rb +55 -6
  51. data/spec/base_object_spec.rb +13 -0
  52. data/spec/cert_utils_spec.rb +92 -0
  53. data/spec/id_spec.rb +29 -0
  54. data/spec/ldap_sync_spec.rb +21 -0
  55. data/spec/spec_helper.rb +3 -0
  56. data/spec/uri_escape_spec.rb +14 -2
  57. data/test.sh +23 -1
  58. metadata +34 -12
  59. data/LICENSE.md +0 -195
  60. 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
- # Copyright 2013-2017 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.
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
- # 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.
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).post(options.merge(id: id)).body
39
+ response = url_for(:host_factory_create_host, token)
40
+ .post(options.merge(id: id)).body
41
+
44
42
  attributes = JSON.parse(response)
45
- Host.new(attributes['id'], {}).tap do |host|
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-2017 Conjur Inc
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
- module Cast
24
- protected
25
-
26
- # Convert a value to a role or resource identifier.
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 obj the value to cast
29
- def cast_to_id obj
30
- result =if obj.is_a?(String) || obj.is_a?(Id)
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
@@ -1,34 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2013-2018 CyberArk Ltd.
1
4
  #
2
- # Copyright 2013-2017 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.
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
- # 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.
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 it's id. The id given to this method must be qualified by a kind, but the account is
31
- # optional.
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|
@@ -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'][path_escape account]["api_key?role=#{id}"]
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'][path_escape account]['policy'][path_escape id]
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'][path_escape username]
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/#{path_escape account}"
65
- path += "/#{path_escape kind}" if kind
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] = path_escape(cast_to_id(role)) if 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
@@ -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
@@ -1,37 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2013-2018 CyberArk Ltd.
1
4
  #
2
- # Copyright 2013-2017 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.
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
- # 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.
9
+ # http://www.apache.org/licenses/LICENSE-2.0
20
10
  #
21
- require 'conjur/cast'
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 = cast_to_id(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; id.account; end
45
- def kind; id.kind; end
46
- def identifier; id.identifier; end
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
@@ -1,37 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2013-2018 CyberArk Ltd.
1
4
  #
2
- # Copyright 2013-2017 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.
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
- # 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.
9
+ # http://www.apache.org/licenses/LICENSE-2.0
20
10
  #
21
- require 'conjur/cast'
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 = cast_to_id(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)