cf-uaac 3.13.0 → 3.13.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/cf-uaac.gemspec +1 -1
- data/lib/uaa/cli/group.rb +95 -17
- data/lib/uaa/cli/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ef367062c3e28c384a318cbf086099558e965a4
|
4
|
+
data.tar.gz: 2cc9ad180ad1a8ccdb88eab48191cc8931bd336c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c56c0743dbede318336371e6d731d0f6d895a949f41905bc60cd492348a8ae818b21cf4f0f7cbb85ebc5ae3a5b46195c44e674315a074fa97d3df55325adbfc6
|
7
|
+
data.tar.gz: ade14cd1d7aeec495397587b486327cf046794e68c8a5a902005b25f0124b8db7c9d50e966f828bcf3fe390ee0c15bc4e22c75a4e52de6481f1249598a50c17a
|
data/cf-uaac.gemspec
CHANGED
@@ -33,7 +33,7 @@ Gem::Specification.new do |s|
|
|
33
33
|
s.require_paths = ['lib']
|
34
34
|
|
35
35
|
# dependencies
|
36
|
-
s.add_runtime_dependency 'cf-uaa-lib', '~> 3.
|
36
|
+
s.add_runtime_dependency 'cf-uaa-lib', '~> 3.11'
|
37
37
|
s.add_development_dependency 'bundler', '~> 1.14'
|
38
38
|
s.add_development_dependency 'rake', '~> 10.3', '>= 10.3.1'
|
39
39
|
s.add_development_dependency 'rspec', '~> 2.14', '>= 2.14.1'
|
data/lib/uaa/cli/group.rb
CHANGED
@@ -106,30 +106,108 @@ class GroupCli < CommonCli
|
|
106
106
|
}
|
107
107
|
end
|
108
108
|
|
109
|
-
def
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
109
|
+
def find_members(scim, members)
|
110
|
+
found_members = []
|
111
|
+
|
112
|
+
scim.ids(:user, *members).each do |member|
|
113
|
+
found_members << {
|
114
|
+
'type' => 'USER',
|
115
|
+
'value' => member['id'],
|
116
|
+
'origin' => member['origin']
|
117
|
+
}
|
118
|
+
end
|
119
|
+
|
120
|
+
found_members
|
121
|
+
end
|
122
|
+
|
123
|
+
def union(old_members, new_members)
|
124
|
+
old_ids = id_set(old_members)
|
125
|
+
all_members = old_members.clone
|
126
|
+
|
127
|
+
new_members.each do |member|
|
128
|
+
unless old_ids.include?(member['value'])
|
129
|
+
all_members << member
|
122
130
|
end
|
123
|
-
|
124
|
-
|
131
|
+
end
|
132
|
+
|
133
|
+
all_members
|
134
|
+
end
|
135
|
+
|
136
|
+
def difference(old_members, new_members)
|
137
|
+
new_ids = id_set(new_members)
|
138
|
+
|
139
|
+
old_members.reject do |member|
|
140
|
+
new_ids.include?(member['value'])
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
def add_members(scim, name, members)
|
145
|
+
group = scim_get_object(scim, :group, gname(name))
|
146
|
+
|
147
|
+
old_members = (group['members'] || [])
|
148
|
+
new_members = find_members(scim, members)
|
149
|
+
|
150
|
+
unless new_members.size == members.size
|
151
|
+
raise 'not all users found, none added'
|
152
|
+
end
|
153
|
+
|
154
|
+
group['members'] = union(old_members, new_members)
|
155
|
+
|
156
|
+
unless group['members'].size > old_members.size
|
157
|
+
raise 'no new users given'
|
158
|
+
end
|
159
|
+
|
160
|
+
scim.put(:group, group)
|
161
|
+
'success'
|
162
|
+
end
|
163
|
+
|
164
|
+
def delete_members(scim, name, members)
|
165
|
+
group = scim_get_object(scim, :group, gname(name))
|
166
|
+
|
167
|
+
old_members = (group['members'] || [])
|
168
|
+
new_members = find_members(scim, members)
|
169
|
+
|
170
|
+
unless new_members.size == members.size
|
171
|
+
raise 'not all users found, none deleted'
|
172
|
+
end
|
173
|
+
|
174
|
+
group['members'] = difference(old_members, new_members)
|
175
|
+
|
176
|
+
unless group['members'].size < old_members.size
|
177
|
+
raise 'no existing users to delete'
|
178
|
+
end
|
179
|
+
|
180
|
+
group.delete('members') if group['members'].empty?
|
181
|
+
|
182
|
+
scim.put(:group, group)
|
183
|
+
'success'
|
184
|
+
end
|
185
|
+
|
186
|
+
def update_members(scim, name, attr, users, add = true)
|
187
|
+
group = scim_get_object(scim, :group, gname(name))
|
188
|
+
old_ids = id_set(group[attr] || [])
|
189
|
+
new_ids = id_set(scim.ids(:user, *users))
|
190
|
+
if add
|
191
|
+
raise 'not all users found, none added' unless new_ids.size == users.size
|
192
|
+
group[attr] = (old_ids + new_ids).to_a
|
193
|
+
raise 'no new users given' unless group[attr].size > old_ids.size
|
194
|
+
else
|
195
|
+
raise 'not all users found, none deleted' unless new_ids.size == users.size
|
196
|
+
group[attr] = (old_ids - new_ids).to_a
|
197
|
+
raise 'no existing users to delete' unless group[attr].size < old_ids.size
|
198
|
+
group.delete(attr) if group[attr].empty?
|
199
|
+
end
|
200
|
+
|
201
|
+
scim.put(:group, group)
|
202
|
+
'success'
|
125
203
|
end
|
126
204
|
|
127
205
|
desc "member add [name] [users...]", "add members to a group" do |name, *users|
|
128
|
-
pp scim_request { |scim|
|
206
|
+
pp scim_request { |scim| add_members(scim, name, users) }
|
129
207
|
end
|
130
208
|
|
131
209
|
desc "member delete [name] [users...]", "remove members from a group" do |name, *users|
|
132
|
-
pp scim_request { |scim|
|
210
|
+
pp scim_request { |scim| delete_members(scim, name, users) }
|
133
211
|
end
|
134
212
|
|
135
213
|
desc "group reader add [name] [users...]", "add users who can read the members" do |name, *users|
|
data/lib/uaa/cli/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cf-uaac
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.13.
|
4
|
+
version: 3.13.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dave Syer
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2017-07-
|
15
|
+
date: 2017-07-28 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: cf-uaa-lib
|
@@ -20,14 +20,14 @@ dependencies:
|
|
20
20
|
requirements:
|
21
21
|
- - "~>"
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 3.
|
23
|
+
version: '3.11'
|
24
24
|
type: :runtime
|
25
25
|
prerelease: false
|
26
26
|
version_requirements: !ruby/object:Gem::Requirement
|
27
27
|
requirements:
|
28
28
|
- - "~>"
|
29
29
|
- !ruby/object:Gem::Version
|
30
|
-
version: 3.
|
30
|
+
version: '3.11'
|
31
31
|
- !ruby/object:Gem::Dependency
|
32
32
|
name: bundler
|
33
33
|
requirement: !ruby/object:Gem::Requirement
|