conjur-asset-policy 0.8.2 → 0.8.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/conjur-asset-policy-version.rb +1 -1
- data/lib/conjur-asset-policy.rb +3 -0
- data/lib/conjur/api/patches/role.rb +14 -0
- data/lib/conjur/policy/planner/base.rb +23 -9
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d3f421be05da2eced0b95bfa1028a1a3e01695f
|
4
|
+
data.tar.gz: 73121a9f79529fae31f28c8f7ed08842b8481bd8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 857b7d9be7f6a76d6721b51c8a479fb78ad125efbbf76ade98d10671e6b7cfc561c4b39a5dc5466b0801a482aed09c2feab439cff839532565a89e7d56a2e7f7
|
7
|
+
data.tar.gz: 1208b5fefe05b10c7d7c7b212f76cbda8344eaaf141b9c3d62181720db172a8056bc18f15b8122b8a7cdbbdd7ec4532afac6faa63678dc5387d52a479c04e7f8
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
# 0.8.3
|
2
|
+
|
3
|
+
* When re-loading a policy, properly apply `--as-group` and `--as-role` by changing the ownership of top-level records as needed.
|
4
|
+
|
1
5
|
# 0.8.2
|
2
6
|
|
3
7
|
* When user is created with a namespace, form an id that looks like an email address with the namespace as the domain.
|
data/lib/conjur-asset-policy.rb
CHANGED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'conjur/api'
|
2
|
+
|
3
|
+
class Conjur::Role
|
4
|
+
# This role can admin the target +role+ if this role has a role which is an admin member of
|
5
|
+
# +role+. This determination is made by expanding all roles of +self+, then doing the set
|
6
|
+
# intersection with the direct members of +role+, and looking for an overlapping member that
|
7
|
+
# has +admin_option+.
|
8
|
+
def can_admin_role? role
|
9
|
+
return true if self.roleid == role.roleid
|
10
|
+
|
11
|
+
memberships = self.memberships.map(&:roleid)
|
12
|
+
role.members.any?{|m| memberships.include?(m.member.roleid) && m.admin_option}
|
13
|
+
end
|
14
|
+
end
|
@@ -90,6 +90,8 @@ module Conjur
|
|
90
90
|
end
|
91
91
|
|
92
92
|
def update_record
|
93
|
+
log { "Updating #{record}" }
|
94
|
+
|
93
95
|
update = Conjur::Policy::Types::Update.new
|
94
96
|
update.record = record
|
95
97
|
|
@@ -106,6 +108,7 @@ module Conjur
|
|
106
108
|
record.send "#{attr}=", nil
|
107
109
|
else
|
108
110
|
raise "Cannot modify immutable attribute '#{record.resource_kind}.#{attr}'" if record.immutable_attribute_names.member?(attr)
|
111
|
+
log { "Attribute #{attr} will be updated" }
|
109
112
|
changed = true
|
110
113
|
end
|
111
114
|
end
|
@@ -120,24 +123,33 @@ module Conjur
|
|
120
123
|
if new_value == existing_value
|
121
124
|
record.annotations.delete attr
|
122
125
|
else
|
126
|
+
log { "Annotation #{attr} will be updated" }
|
123
127
|
changed = true
|
124
128
|
end
|
125
129
|
end
|
126
130
|
|
131
|
+
log { "Record owner is #{record.owner.roleid}" }
|
132
|
+
log { "Resource owner is #{resource.owner}" }
|
127
133
|
if record.owner && resource.owner != record.owner.roleid
|
134
|
+
log { "Resource owner will be changed to #{record.owner.roleid}" }
|
135
|
+
|
128
136
|
give = Conjur::Policy::Types::Give.new
|
129
137
|
give.resource = Conjur::Policy::Types::Resource.new(record.resourceid)
|
130
138
|
give.owner = Conjur::Policy::Types::Role.new(record.owner.roleid)
|
131
139
|
action give
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
if record.role?
|
144
|
+
unless api.role(record.owner.roleid).can_admin_role?(role)
|
145
|
+
log { "Role will be granted to #{record.owner.roleid} with admin option" }
|
146
|
+
|
147
|
+
grant = Conjur::Policy::Types::Grant.new
|
148
|
+
grant.role = Conjur::Policy::Types::Role.new(record.roleid)
|
149
|
+
grant.member = Conjur::Policy::Types::Member.new
|
150
|
+
grant.member.role = Conjur::Policy::Types::Role.new(record.owner.roleid)
|
151
|
+
grant.member.admin = true
|
152
|
+
action grant
|
141
153
|
end
|
142
154
|
end
|
143
155
|
|
@@ -145,6 +157,8 @@ module Conjur
|
|
145
157
|
end
|
146
158
|
|
147
159
|
def create_record
|
160
|
+
log { "Creating #{record}" }
|
161
|
+
|
148
162
|
create = Conjur::Policy::Types::Create.new
|
149
163
|
create.record = record
|
150
164
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: conjur-asset-policy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Gilpin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: safe_yaml
|
@@ -188,6 +188,7 @@ files:
|
|
188
188
|
- jenkins.sh
|
189
189
|
- lib/conjur-asset-policy-version.rb
|
190
190
|
- lib/conjur-asset-policy.rb
|
191
|
+
- lib/conjur/api/patches/role.rb
|
191
192
|
- lib/conjur/command/policy.rb
|
192
193
|
- lib/conjur/policy/doc.rb
|
193
194
|
- lib/conjur/policy/executor.rb
|