conjur-api 2.1.4 → 2.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/conjur-api/version.rb +1 -1
- data/lib/conjur/acts_as_asset.rb +3 -3
- data/lib/conjur/acts_as_resource.rb +2 -1
- data/lib/conjur/api.rb +4 -0
- data/lib/conjur/base.rb +10 -3
- data/lib/conjur/has_attributes.rb +4 -0
- data/lib/conjur/has_id.rb +4 -0
- data/lib/conjur/role.rb +4 -2
- data/lib/conjur/role_grant.rb +11 -0
- metadata +4 -3
data/lib/conjur-api/version.rb
CHANGED
data/lib/conjur/acts_as_asset.rb
CHANGED
@@ -2,11 +2,11 @@ module Conjur
|
|
2
2
|
module ActsAsAsset
|
3
3
|
def self.included(base)
|
4
4
|
base.instance_eval do
|
5
|
-
include ActsAsResource
|
6
|
-
include HasAttributes
|
7
|
-
include Exists
|
8
5
|
include HasId
|
6
|
+
include Exists
|
9
7
|
include HasOwner
|
8
|
+
include ActsAsResource
|
9
|
+
include HasAttributes
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
data/lib/conjur/api.rb
CHANGED
data/lib/conjur/base.rb
CHANGED
@@ -20,9 +20,16 @@ module Conjur
|
|
20
20
|
class << self
|
21
21
|
# Parse a role id into [ account, 'roles', kind, id ]
|
22
22
|
def parse_role_id(id)
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
if id.is_a?(Hash)
|
24
|
+
tokens = id['id'].split(':')
|
25
|
+
[ id['account'], 'roles', tokens[0], tokens[1..-1].join(':') ]
|
26
|
+
elsif id.is_a?(String)
|
27
|
+
paths = path_escape(id).split(':')
|
28
|
+
raise "Expecting account:kind:id in role #{id}" unless paths.size >= 3
|
29
|
+
[ paths[0], 'roles', paths[1], paths[2..-1].join(':') ]
|
30
|
+
else
|
31
|
+
raise "Unexpected class #{id.class} for #{id}"
|
32
|
+
end
|
26
33
|
end
|
27
34
|
|
28
35
|
def new_from_key(username, api_key)
|
data/lib/conjur/has_id.rb
CHANGED
data/lib/conjur/role.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'conjur/role_grant'
|
2
|
+
|
1
3
|
module Conjur
|
2
4
|
class Role < RestClient::Resource
|
3
5
|
include Exists
|
@@ -61,8 +63,8 @@ module Conjur
|
|
61
63
|
end
|
62
64
|
|
63
65
|
def members
|
64
|
-
JSON.parse(self["?members"].get(options)).collect do |
|
65
|
-
|
66
|
+
JSON.parse(self["?members"].get(options)).collect do |json|
|
67
|
+
RoleGrant.parse_from_json(json, self.options)
|
66
68
|
end
|
67
69
|
end
|
68
70
|
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module Conjur
|
2
|
+
RoleGrant = Struct.new(:member, :grantor, :admin_option) do
|
3
|
+
class << self
|
4
|
+
def parse_from_json(json, credentials)
|
5
|
+
member = Role.new(Conjur::Authz::API.host, credentials)[Conjur::API.parse_role_id(json['member']).join('/')]
|
6
|
+
grantor = Role.new(Conjur::Authz::API.host, credentials)[Conjur::API.parse_role_id(json['grantor']).join('/')]
|
7
|
+
RoleGrant.new(member, grantor, json['admin_option'])
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
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: 2.1.
|
4
|
+
version: 2.1.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -178,6 +178,7 @@ files:
|
|
178
178
|
- lib/conjur/path_based.rb
|
179
179
|
- lib/conjur/resource.rb
|
180
180
|
- lib/conjur/role.rb
|
181
|
+
- lib/conjur/role_grant.rb
|
181
182
|
- lib/conjur/secret.rb
|
182
183
|
- lib/conjur/standard_methods.rb
|
183
184
|
- lib/conjur/token_cache.rb
|
@@ -205,7 +206,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
205
206
|
version: '0'
|
206
207
|
segments:
|
207
208
|
- 0
|
208
|
-
hash:
|
209
|
+
hash: -713472322401587532
|
209
210
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
210
211
|
none: false
|
211
212
|
requirements:
|
@@ -214,7 +215,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
214
215
|
version: '0'
|
215
216
|
segments:
|
216
217
|
- 0
|
217
|
-
hash:
|
218
|
+
hash: -713472322401587532
|
218
219
|
requirements: []
|
219
220
|
rubyforge_project:
|
220
221
|
rubygems_version: 1.8.24
|